summaryrefslogtreecommitdiffstats
path: root/kernel/smpboot.c
AgeCommit message (Expand)Author
2016-10-11kthread/smpboot: do not park in kthread_create_on_cpu()Petr Mladek
2016-10-04Revert "sched/core: Do not use smp_processor_id() with preempt enabled in smp...Ingo Molnar
2016-09-22sched/core: Do not use smp_processor_id() with preempt enabled in smpboot_thr...Con Kolivas
2016-03-01cpu/hotplug: Unpark smpboot threads from the state machineThomas Gleixner
2015-10-20stop_machine: Kill smp_hotplug_thread->pre_unpark, introduce stop_machine_unp...Oleg Nesterov
2015-09-04smpboot: allow passing the cpumask on per-cpu thread registrationFrederic Weisbecker
2015-09-04smpboot: make cleanup to mirror setupFrederic Weisbecker
2015-09-04smpboot: fix memory leak on error handlingFrederic Weisbecker
2015-06-242013-07-14kernel: delete __cpuinit usage from all core kernel filesPaul Gortmaker
2013-04-12kthread: Prevent unpark race which puts threads on the wrong cpuThomas Gleixner
2013-03-08Revert parts of "hlist: drop the node parameter from iterators"Arnd Bergmann
2013-03-05Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds
2013-02-27hlist: drop the node parameter from iteratorsSasha Levin
2013-02-26stop_machine: Mark per cpu stopper enabled earlyThomas Gleixner
2013-02-14smpboot: Allow selfparking per cpu threadsThomas Gleixner
2012-08-13hotplug: Fix UP bug in smpboot hotplug codePaul E. McKenney
2012-08-13smpboot: Provide infrastructure for percpu hotplug threadsThomas Gleixner
2012-05-24smpboot, idle: Fix comment mismatch over idle_threads_init()Srivatsa S. Bhat
2012-05-24smpboot, idle: Optimize calls to smp_processor_id() in idle_threads_init()Srivatsa S. Bhat
2012-05-03smp, idle: Allocate idle thread for each possible cpu during bootSuresh Siddha
2012-04-26smp: Provide generic idle thread allocationThomas Gleixner
2012-04-26smp: Add generic smpboot facilityThomas Gleixner
n.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
const LINE_BREAK_TABLE_URL: &str = "http://www.unicode.org/Public/UCD/latest/ucd/LineBreak.txt";
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::PathBuf;
use std::process::Command;

include!("src/text_processing/types.rs");

fn main() -> Result<(), std::io::Error> {
    let mod_path = PathBuf::from("src/text_processing/tables.rs");
    if mod_path.exists() {
        eprintln!(
            "{} already exists, delete it if you want to replace it.",
            mod_path.display()
        );
        std::process::exit(0);
    }
    let mut tmpdir_path = PathBuf::from(
        std::str::from_utf8(&Command::new("mktemp").arg("-d").output()?.stdout)
            .unwrap()
            .trim(),
    );
    tmpdir_path.push("LineBreak.txt");
    Command::new("curl")
        .args(&["-o", tmpdir_path.to_str().unwrap(), LINE_BREAK_TABLE_URL])
        .output()?;

    let file = File::open(&tmpdir_path)?;
    let buf_reader = BufReader::new(file);

    let mut line_break_table: Vec<(u32, u32, LineBreakClass)> = Vec::with_capacity(3800);
    for line in buf_reader.lines() {
        let line = line.unwrap();
        if line.starts_with('#') || line.starts_with(' ') || line.is_empty() {
            continue;
        }
        let tokens: &str = line.split_whitespace().next().unwrap();

        let semicolon_idx: usize = tokens.chars().position(|c| c == ';').unwrap();
        /* LineBreak.txt list is ascii encoded so we can assume each char takes one byte: */
        let chars_str: &str = &tokens[..semicolon_idx];

        let mut codepoint_iter = chars_str.split("..");

        let first_codepoint: u32 =
            u32::from_str_radix(std::dbg!(codepoint_iter.next().unwrap()), 16).unwrap();

        let sec_codepoint: u32 = codepoint_iter
            .next()
            .map(|v| u32::from_str_radix(std::dbg!(v), 16).unwrap())
            .unwrap_or(first_codepoint);
        let class = &tokens[semicolon_idx + 1..semicolon_idx + 1 + 2];
        line_break_table.push((first_codepoint, sec_codepoint, LineBreakClass::from(class)));
    }

    let mut file = File::create(&mod_path)?;
    file.write_all(b"use crate::types::LineBreakClass::*;\n")
        .unwrap();
    file.write_all(b"use crate::types::LineBreakClass;\n\n")
        .unwrap();
    file.write_all(b"const line_break_rules: &'static [(u32, u32, LineBreakClass)] = &[\n")
        .unwrap();
    for l in &line_break_table {
        file.write_all(format!("    (0x{:X}, 0x{:X}, {:?}),\n", l.0, l.1, l.2).as_bytes())
            .unwrap();
    }
    file.write_all(b"];").unwrap();
    std::fs::remove_file(&tmpdir_path).unwrap();
    tmpdir_path.pop();
    std::fs::remove_dir(&tmpdir_path).unwrap();
    Ok(())
}