-
Notifications
You must be signed in to change notification settings - Fork 91
Isolate shared C files to a common shared library #1693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
95f264d
4f1f0e8
42a08bf
08eaaf6
a8a480d
c54307f
417da10
002d286
c7e6966
e4a577a
0d036c3
53bdf5e
4762d67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,6 +158,9 @@ module Make(O:Config)(Tar:Tar.S) = | |
| close_in in_chan ; | ||
| fnames | ||
|
|
||
| (* Reference to the shared library *) | ||
| let shared_lib = if Tar.is_archive then "shared_lib/" else "../shared_lib/" | ||
|
|
||
| (* Copy lib file *) | ||
| let cpy ?sub ?prf fnames name ext = | ||
| do_cpy ?sub ?prf fnames ("_" ^ name) name ext | ||
|
|
@@ -166,6 +169,14 @@ module Make(O:Config)(Tar:Tar.S) = | |
| let cpy' ?sub ?prf fnames src dst ext = | ||
| do_cpy ?sub ?prf fnames ("_" ^ src) dst ext | ||
|
|
||
| (* Copy lib file to shared library *) | ||
| let cpy_shared ?sub ?prf fnames name ext = | ||
z5146542 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| do_cpy ?sub ?prf fnames ("_" ^ name) (shared_lib ^ name) ext | ||
|
|
||
| (* Copy lib file to shared library, changing its name *) | ||
| let cpy'_shared ?sub ?prf fnames src dst ext = | ||
ShaleXIONG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| do_cpy ?sub ?prf fnames ("_" ^ src) (shared_lib ^ dst) ext | ||
|
|
||
| (* Copy from platform subdirectory *) | ||
| let cpy_platform fnames name ext = | ||
| let name = sprintf "platform_%s" name in | ||
|
|
@@ -175,6 +186,15 @@ module Make(O:Config)(Tar:Tar.S) = | |
| | Mode.PreSi|Mode.Std -> O.platform in | ||
| do_cpy fnames (Filename.concat platform name) name ext | ||
|
|
||
| (* Copy from platform subdirectory to shared library *) | ||
| let cpy_shared_platform fnames name ext = | ||
|
||
| let name = sprintf "platform_%s" name in | ||
| let platform = | ||
| match O.mode with | ||
| | Mode.Kvm -> "_kvm" ^ O.platform | ||
| | Mode.PreSi|Mode.Std -> O.platform in | ||
| do_cpy fnames (Filename.concat platform name) (shared_lib ^ name) ext | ||
|
|
||
| let affinity_base () = match O.targetos with | ||
| | Linux|FreeBsd -> "_linux_affinity" | ||
| | AIX -> "_aix_affinity" | ||
|
|
@@ -183,6 +203,9 @@ module Make(O:Config)(Tar:Tar.S) = | |
| Warn.fatal "Affinity not implemented for %s" (TargetOS.pp os) | ||
|
|
||
| let dump flags = | ||
| (* Create shared library directory *) | ||
| let () = MySys.mkdirp (Tar.outname shared_lib) in | ||
|
|
||
| let fnames = [] in | ||
| let fnames = match O.driver with | ||
| | Driver.Shell -> fnames | ||
|
|
@@ -205,22 +228,22 @@ module Make(O:Config)(Tar:Tar.S) = | |
| |`BPF | `CPP|`LISA | `JAVA | `ASL -> Warn.fatal "no support for arch '%s'" (Archs.pp O.arch) | ||
| in | ||
| let fnames = | ||
| let fnames = cpy fnames "litmus_rand" ".c" in | ||
| let fnames = cpy fnames "litmus_rand" ".h" in | ||
| let fnames = cpy_shared fnames "litmus_rand" ".c" in | ||
| let fnames = cpy_shared fnames "litmus_rand" ".h" in | ||
| let sub = dir_of_sysarch O.sysarch in | ||
| let fnames = cpy ~sub:sub fnames "cache" ".h" in | ||
| let fnames = cpy_shared ~sub:sub fnames "cache" ".h" in | ||
| fnames in | ||
| let fnames = | ||
| if O.stdio then fnames | ||
| else | ||
| let fnames = cpy_platform fnames "io" ".c" in | ||
| let fnames = cpy_platform fnames "io" ".h" in | ||
| let fnames = cpy fnames "litmus_io" ".c" in | ||
| let fnames = cpy fnames "litmus_io" ".h" in | ||
| let fnames = cpy_shared_platform fnames "io" ".c" in | ||
| let fnames = cpy_shared_platform fnames "io" ".h" in | ||
| let fnames = cpy_shared fnames "litmus_io" ".c" in | ||
| let fnames = cpy_shared fnames "litmus_io" ".h" in | ||
| fnames in | ||
| let fnames = match O.mode with | ||
| | Mode.Std -> | ||
| let fnames = cpy fnames "utils" ".c" in | ||
| let fnames = cpy_shared fnames "utils" ".c" in | ||
| (* Select cached conditional variables, disabled. | ||
| if O.cached then | ||
| cpy ~prf:"#define CACHE 1" fnames "utils" ".h" | ||
|
|
@@ -229,29 +252,30 @@ module Make(O:Config)(Tar:Tar.S) = | |
| | Mode.PreSi -> | ||
| if do_dynalloc then | ||
| let fnames = | ||
| cpy' ~prf:"#define DYNALLOC 1" fnames "presi" "utils" ".c" in | ||
| cpy' ~prf:"#define DYNALLOC 1" fnames "presi" "utils" ".h" | ||
| cpy'_shared ~prf:"#define DYNALLOC 1" fnames "presi" "utils" ".c" in | ||
| cpy'_shared ~prf:"#define DYNALLOC 1" fnames "presi" "utils" ".h" | ||
| else | ||
| let fnames = cpy' fnames "presi" "utils" ".c" in | ||
| let fnames = cpy'_shared fnames "presi" "utils" ".c" in | ||
| cpy' fnames "presi" "utils" ".h" | ||
| | Mode.Kvm -> | ||
| let prf = | ||
| if do_dynalloc then | ||
| "#define KVM 1\n#define DYNALLOC 1" | ||
| else | ||
| "#define KVM 1" in | ||
| let fnames = cpy' ~prf:prf fnames "presi" "utils" ".c" in | ||
| let fnames = cpy' ~prf:prf fnames "presi" "utils" ".h" in | ||
| let fnames = cpy fnames "kvm_timeofday" ".h" in | ||
| let fnames = cpy'_shared ~prf:prf fnames "presi" "utils" ".c" in | ||
| let fnames = cpy'_shared ~prf:prf fnames "presi" "utils" ".h" in | ||
| let fnames = cpy_shared fnames "kvm_timeofday" ".h" in | ||
| let module I = Insert(O) in | ||
| I.copy "kvm_timeofday.c" Tar.outname ; | ||
| I.copy "kvm-headers.h" Tar.outname ; | ||
| let tar_outname = (fun str -> Tar.outname (shared_lib ^ str)) in | ||
| I.copy "kvm_timeofday.c" tar_outname ; | ||
| I.copy "kvm-headers.h" tar_outname ; | ||
| fnames in | ||
| let fnames = | ||
| match O.mode with | ||
| | Mode.Std -> | ||
| let fnames = cpy fnames "outs" ".c" in | ||
| let fnames = cpy fnames "outs" ".h" in | ||
| let fnames = cpy_shared fnames "outs" ".c" in | ||
| let fnames = cpy_shared fnames "outs" ".h" in | ||
| fnames | ||
| | Mode.PreSi|Mode.Kvm -> | ||
| fnames in | ||
|
|
@@ -260,23 +284,23 @@ module Make(O:Config)(Tar:Tar.S) = | |
| | Affinity.No -> fnames | ||
| | _ -> | ||
| let affi = affinity_base () in | ||
| let fnames = do_cpy fnames affi "affinity" ".c" in | ||
| let fnames = cpy fnames "affinity" ".h" in | ||
| let fnames = do_cpy fnames affi (shared_lib ^ "affinity") ".c" in | ||
| let fnames = cpy_shared fnames "affinity" ".h" in | ||
| fnames in | ||
| let fnames = | ||
| if flags.Flags.memtag then | ||
| begin | ||
| let sub = dir_of_sysarch O.sysarch in | ||
| let fnames = cpy ~sub:sub fnames "memtag" ".c" in | ||
| let fnames = cpy ~sub:sub fnames "memtag" ".h" in | ||
| let fnames = cpy_shared ~sub:sub fnames "memtag" ".c" in | ||
| let fnames = cpy_shared ~sub:sub fnames "memtag" ".h" in | ||
| fnames | ||
| end | ||
| else fnames in | ||
| let fnames = | ||
| if flags.Flags.pac then | ||
| let sub = dir_of_sysarch O.sysarch in | ||
| let fnames = cpy ~sub:sub fnames "auth" ".c" in | ||
| let fnames = cpy ~sub:sub fnames "auth" ".h" in | ||
| let fnames = cpy_shared ~sub:sub fnames "auth" ".c" in | ||
| let fnames = cpy_shared ~sub:sub fnames "auth" ".h" in | ||
| fnames | ||
| else fnames in | ||
| fnames | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.