Mercurial > hg > toybox
comparison toys/posix/uname.c @ 674:7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 08 Oct 2012 00:02:30 -0500 |
parents | 6df4ccc0acbe |
children | fa858a67e231 |
comparison
equal
deleted
inserted
replaced
673:c102f31a753e | 674:7e846e281e38 |
---|---|
22 -v Version (build date) | 22 -v Version (build date) |
23 -m Machine (hardware) name | 23 -m Machine (hardware) name |
24 -a All of the above | 24 -a All of the above |
25 */ | 25 */ |
26 | 26 |
27 #define FOR_uname | |
27 #include "toys.h" | 28 #include "toys.h" |
28 | 29 |
29 // If a 32 bit x86 build environment working in a chroot under an x86-64 | 30 // If a 32 bit x86 build environment working in a chroot under an x86-64 |
30 // kernel returns x86_64 for -m it confuses ./configure. Special case it. | 31 // kernel returns x86_64 for -m it confuses ./configure. Special case it. |
31 | 32 |
37 #define GROSS "i486" | 38 #define GROSS "i486" |
38 #elif defined(__i386__) | 39 #elif defined(__i386__) |
39 #define GROSS "i386" | 40 #define GROSS "i386" |
40 #endif | 41 #endif |
41 | 42 |
42 #define FLAG_a (1<<5) | |
43 | |
44 void uname_main(void) | 43 void uname_main(void) |
45 { | 44 { |
46 int i, flags = toys.optflags, needspace=0; | 45 int i, flags = toys.optflags, needspace=0; |
47 | 46 |
48 uname((void *)toybuf); | 47 uname((void *)toybuf); |
49 | 48 |
50 if (!flags) flags=1; | 49 if (!flags) flags = FLAG_s; |
51 for (i=0; i<5; i++) { | 50 for (i=0; i<5; i++) { |
52 char *c = toybuf+(65*i); | 51 char *c = toybuf+(65*i); |
53 | 52 |
54 if (flags & ((1<<i)|FLAG_a)) { | 53 if (flags & ((1<<i)|FLAG_a)) { |
55 int len = strlen(c); | 54 int len = strlen(c); |