Skip to content

Commit 7008170

Browse files
committed
Fix style errors
1 parent ca956e1 commit 7008170

File tree

6 files changed

+150
-114
lines changed

6 files changed

+150
-114
lines changed

src/cloudabi/mod.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,24 @@ extern {
134134
pub fn isxdigit(c: ::c_int) -> ::c_int;
135135
pub fn tolower(c: ::c_int) -> ::c_int;
136136
pub fn toupper(c: ::c_int) -> ::c_int;
137-
pub fn fopen(filename: *const ::c_char, mode: *const ::c_char) -> *mut FILE;
137+
pub fn fopen(filename: *const ::c_char,
138+
mode: *const ::c_char) -> *mut FILE;
138139
pub fn freopen(filename: *const ::c_char, mode: *const ::c_char,
139140
file: *mut FILE) -> *mut FILE;
140141
pub fn fflush(file: *mut FILE) -> ::c_int;
141142
pub fn fclose(file: *mut FILE) -> ::c_int;
142143
pub fn remove(filename: *const ::c_char) -> ::c_int;
143-
pub fn rename(oldname: *const ::c_char, newname: *const ::c_char) -> ::c_int;
144+
pub fn rename(oldname: *const ::c_char,
145+
newname: *const ::c_char) -> ::c_int;
144146
pub fn tmpfile() -> *mut FILE;
145147
pub fn setvbuf(stream: *mut FILE, buffer: *mut ::c_char, mode: ::c_int,
146148
size: ::size_t) -> ::c_int;
147149
pub fn setbuf(stream: *mut FILE, buf: *mut ::c_char);
148150
pub fn getchar() -> ::c_int;
149151
pub fn putchar(c: ::c_int) -> ::c_int;
150152
pub fn fgetc(stream: *mut FILE) -> ::c_int;
151-
pub fn fgets(buf: *mut ::c_char, n: ::c_int, stream: *mut FILE) -> *mut ::c_char;
153+
pub fn fgets(buf: *mut ::c_char, n: ::c_int,
154+
stream: *mut FILE) -> *mut ::c_char;
152155
pub fn fputc(c: ::c_int, stream: *mut FILE) -> ::c_int;
153156
pub fn fputs(s: *const ::c_char, stream: *mut FILE) -> ::c_int;
154157
pub fn puts(s: *const ::c_char) -> ::c_int;
@@ -157,7 +160,8 @@ extern {
157160
stream: *mut FILE) -> ::size_t;
158161
pub fn fwrite(ptr: *const ::c_void, size: ::size_t, nobj: ::size_t,
159162
stream: *mut FILE) -> ::size_t;
160-
pub fn fseek(stream: *mut FILE, offset: ::c_long, whence: ::c_int) -> ::c_int;
163+
pub fn fseek(stream: *mut FILE, offset: ::c_long,
164+
whence: ::c_int) -> ::c_int;
161165
pub fn ftell(stream: *mut FILE) -> ::c_long;
162166
pub fn rewind(stream: *mut FILE);
163167
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> ::c_int;
@@ -188,9 +192,11 @@ extern {
188192
pub fn strncpy(dst: *mut ::c_char, src: *const ::c_char,
189193
n: ::size_t) -> *mut ::c_char;
190194
pub fn strcat(s: *mut ::c_char, ct: *const ::c_char) -> *mut ::c_char;
191-
pub fn strncat(s: *mut ::c_char, ct: *const ::c_char, n: ::size_t) -> *mut ::c_char;
195+
pub fn strncat(s: *mut ::c_char, ct: *const ::c_char,
196+
n: ::size_t) -> *mut ::c_char;
192197
pub fn strcmp(cs: *const ::c_char, ct: *const ::c_char) -> ::c_int;
193-
pub fn strncmp(cs: *const ::c_char, ct: *const ::c_char, n: ::size_t) -> ::c_int;
198+
pub fn strncmp(cs: *const ::c_char, ct: *const ::c_char,
199+
n: ::size_t) -> ::c_int;
194200
pub fn strcoll(cs: *const ::c_char, ct: *const ::c_char) -> ::c_int;
195201
pub fn strchr(cs: *const ::c_char, c: ::c_int) -> *mut ::c_char;
196202
pub fn strrchr(cs: *const ::c_char, c: ::c_int) -> *mut ::c_char;
@@ -206,18 +212,22 @@ extern {
206212
pub fn strnlen(cs: *const ::c_char, maxlen: ::size_t) -> ::size_t;
207213
pub fn strerror(n: ::c_int) -> *mut ::c_char;
208214
pub fn strtok(s: *mut ::c_char, t: *const ::c_char) -> *mut ::c_char;
209-
pub fn strxfrm(s: *mut ::c_char, ct: *const ::c_char, n: ::size_t) -> ::size_t;
215+
pub fn strxfrm(s: *mut ::c_char, ct: *const ::c_char,
216+
n: ::size_t) -> ::size_t;
210217
pub fn wcslen(buf: *const wchar_t) -> ::size_t;
211218
pub fn wcstombs(dest: *mut ::c_char, src: *const wchar_t,
212219
n: ::size_t) -> ::size_t;
213220

214-
pub fn memchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
215-
pub fn memcmp(cx: *const ::c_void, ct: *const ::c_void, n: ::size_t) -> ::c_int;
221+
pub fn memchr(cx: *const ::c_void, c: ::c_int,
222+
n: ::size_t) -> *mut ::c_void;
223+
pub fn memcmp(cx: *const ::c_void, ct: *const ::c_void,
224+
n: ::size_t) -> ::c_int;
216225
pub fn memcpy(dest: *mut ::c_void, src: *const ::c_void,
217226
n: ::size_t) -> *mut ::c_void;
218227
pub fn memmove(dest: *mut ::c_void, src: *const ::c_void,
219228
n: ::size_t) -> *mut ::c_void;
220-
pub fn memset(dest: *mut ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
229+
pub fn memset(dest: *mut ::c_void, c: ::c_int,
230+
n: ::size_t) -> *mut ::c_void;
221231

222232
pub fn abs(i: ::c_int) -> ::c_int;
223233
pub fn atof(s: *const ::c_char) -> ::c_double;

src/fuchsia/mod.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,15 +3080,17 @@ extern {
30803080
pub fn fflush(file: *mut FILE) -> ::c_int;
30813081
pub fn fclose(file: *mut FILE) -> ::c_int;
30823082
pub fn remove(filename: *const ::c_char) -> ::c_int;
3083-
pub fn rename(oldname: *const ::c_char, newname: *const ::c_char) -> ::c_int;
3083+
pub fn rename(oldname: *const ::c_char,
3084+
newname: *const ::c_char) -> ::c_int;
30843085
pub fn tmpfile() -> *mut FILE;
30853086
pub fn setvbuf(stream: *mut FILE, buffer: *mut ::c_char, mode: ::c_int,
30863087
size: ::size_t) -> ::c_int;
30873088
pub fn setbuf(stream: *mut FILE, buf: *mut ::c_char);
30883089
pub fn getchar() -> ::c_int;
30893090
pub fn putchar(c: ::c_int) -> ::c_int;
30903091
pub fn fgetc(stream: *mut FILE) -> ::c_int;
3091-
pub fn fgets(buf: *mut ::c_char, n: ::c_int, stream: *mut FILE) -> *mut ::c_char;
3092+
pub fn fgets(buf: *mut ::c_char, n: ::c_int,
3093+
stream: *mut FILE) -> *mut ::c_char;
30923094
pub fn fputc(c: ::c_int, stream: *mut FILE) -> ::c_int;
30933095
pub fn fputs(s: *const ::c_char, stream: *mut FILE) -> ::c_int;
30943096
pub fn puts(s: *const ::c_char) -> ::c_int;
@@ -3097,7 +3099,8 @@ extern {
30973099
stream: *mut FILE) -> ::size_t;
30983100
pub fn fwrite(ptr: *const ::c_void, size: ::size_t, nobj: ::size_t,
30993101
stream: *mut FILE) -> ::size_t;
3100-
pub fn fseek(stream: *mut FILE, offset: ::c_long, whence: ::c_int) -> ::c_int;
3102+
pub fn fseek(stream: *mut FILE, offset: ::c_long,
3103+
whence: ::c_int) -> ::c_int;
31013104
pub fn ftell(stream: *mut FILE) -> ::c_long;
31023105
pub fn rewind(stream: *mut FILE);
31033106
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> ::c_int;
@@ -3129,7 +3132,8 @@ extern {
31293132
pub fn strncat(s: *mut ::c_char, ct: *const ::c_char,
31303133
n: ::size_t) -> *mut ::c_char;
31313134
pub fn strcmp(cs: *const ::c_char, ct: *const ::c_char) -> ::c_int;
3132-
pub fn strncmp(cs: *const ::c_char, ct: *const ::c_char, n: ::size_t) -> ::c_int;
3135+
pub fn strncmp(cs: *const ::c_char, ct: *const ::c_char,
3136+
n: ::size_t) -> ::c_int;
31333137
pub fn strcoll(cs: *const ::c_char, ct: *const ::c_char) -> ::c_int;
31343138
pub fn strchr(cs: *const ::c_char, c: ::c_int) -> *mut ::c_char;
31353139
pub fn strrchr(cs: *const ::c_char, c: ::c_int) -> *mut ::c_char;
@@ -3142,18 +3146,22 @@ extern {
31423146
pub fn strnlen(cs: *const ::c_char, maxlen: ::size_t) -> ::size_t;
31433147
pub fn strerror(n: ::c_int) -> *mut ::c_char;
31443148
pub fn strtok(s: *mut ::c_char, t: *const ::c_char) -> *mut ::c_char;
3145-
pub fn strxfrm(s: *mut ::c_char, ct: *const ::c_char, n: ::size_t) -> ::size_t;
3149+
pub fn strxfrm(s: *mut ::c_char, ct: *const ::c_char,
3150+
n: ::size_t) -> ::size_t;
31463151
pub fn wcslen(buf: *const wchar_t) -> ::size_t;
31473152
pub fn wcstombs(dest: *mut ::c_char, src: *const wchar_t,
31483153
n: ::size_t) -> ::size_t;
31493154

3150-
pub fn memchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
3151-
pub fn memcmp(cx: *const ::c_void, ct: *const ::c_void, n: ::size_t) -> ::c_int;
3155+
pub fn memchr(cx: *const ::c_void, c: ::c_int,
3156+
n: ::size_t) -> *mut ::c_void;
3157+
pub fn memcmp(cx: *const ::c_void, ct: *const ::c_void,
3158+
n: ::size_t) -> ::c_int;
31523159
pub fn memcpy(dest: *mut ::c_void, src: *const ::c_void,
31533160
n: ::size_t) -> *mut ::c_void;
31543161
pub fn memmove(dest: *mut ::c_void, src: *const ::c_void,
31553162
n: ::size_t) -> *mut ::c_void;
3156-
pub fn memset(dest: *mut ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
3163+
pub fn memset(dest: *mut ::c_void, c: ::c_int,
3164+
n: ::size_t) -> *mut ::c_void;
31573165

31583166
pub fn abs(i: ::c_int) -> ::c_int;
31593167
pub fn atof(s: *const ::c_char) -> ::c_double;
@@ -3786,7 +3794,8 @@ extern {
37863794
pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char,
37873795
size: ::size_t) -> ::ssize_t;
37883796
pub fn removexattr(path: *const ::c_char, name: *const ::c_char) -> ::c_int;
3789-
pub fn lremovexattr(path: *const ::c_char, name: *const ::c_char) -> ::c_int;
3797+
pub fn lremovexattr(path: *const ::c_char,
3798+
name: *const ::c_char) -> ::c_int;
37903799
pub fn fremovexattr(filedes: ::c_int, name: *const ::c_char) -> ::c_int;
37913800
pub fn signalfd(fd: ::c_int,
37923801
mask: *const ::sigset_t,

src/generic.rs

Lines changed: 58 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,84 +17,75 @@ pub type size_t = usize;
1717
pub type ptrdiff_t = isize;
1818
pub type ssize_t = isize;
1919

20-
pub const INT_MIN: c_int = -2147483648;
21-
pub const INT_MAX: c_int = 2147483647;
22-
2320
// There are two ways that platforms (in practice) differ in their C types:
2421
// - chars can either be signed or unsigned
2522
// - longs can either be 32-bit or 64-bit
2623

2724
// Whether chars default to signed or unsigned is primarily determined by
2825
// architecture (windows is the main exception here).
29-
pub use self::chars::*;
30-
#[cfg(any(
31-
target_arch = "aarch64",
32-
target_arch = "arm",
33-
target_arch = "armebv7r",
34-
target_arch = "armv5te",
35-
target_arch = "armv7",
36-
target_arch = "armv7r",
37-
target_arch = "armv7s",
38-
target_arch = "asmjs",
39-
target_arch = "wasm32",
40-
target_arch = "wasm64",
41-
target_arch = "powerpc",
42-
target_arch = "powerpc64",
43-
target_arch = "powerpc64le",
44-
target_arch = "s390x",
45-
target_arch = "thumbv6",
46-
target_arch = "thumbv6m",
47-
target_arch = "thummv7",
48-
target_arch = "thumbv7em",
49-
target_arch = "thumbv7m",
50-
target_arch = "thumbv7neon",
51-
target_arch = "tummbv8",
52-
target_arch = "thumbv8m",
53-
target_arch = "thumbv8m.main"
54-
))]
55-
mod chars {
56-
pub type c_char = u8;
57-
pub type wchar_t = u32;
58-
}
59-
60-
#[cfg(any(
61-
target_arch = "i386",
62-
target_arch = "i586",
63-
target_arch = "i686",
64-
target_arch = "x86",
65-
target_arch = "x86_64",
66-
target_arch = "mips",
67-
target_arch = "mips64",
68-
target_arch = "mips64el",
69-
target_arch = "mipsel",
70-
target_arch = "nvptx",
71-
target_arch = "nvptx64",
72-
target_arch = "sparc64",
73-
target_arch = "sparcv9",
74-
target_arch = "riscv64",
75-
target_arch = "riscv32",
76-
target_arch = "riscv32imac",
77-
target_arch = "riscv32imc"
78-
))]
79-
mod chars {
80-
pub type c_char = i8;
81-
pub type wchar_t = i32;
26+
cfg_if! {
27+
if #[cfg(any(target_arch = "aarch64",
28+
target_arch = "arm",
29+
target_arch = "armebv7r",
30+
target_arch = "armv5te",
31+
target_arch = "armv7",
32+
target_arch = "armv7r",
33+
target_arch = "armv7s",
34+
target_arch = "asmjs",
35+
target_arch = "wasm32",
36+
target_arch = "wasm64",
37+
target_arch = "powerpc",
38+
target_arch = "powerpc64",
39+
target_arch = "powerpc64le",
40+
target_arch = "s390x",
41+
target_arch = "thumbv6",
42+
target_arch = "thumbv6m",
43+
target_arch = "thummv7",
44+
target_arch = "thumbv7em",
45+
target_arch = "thumbv7m",
46+
target_arch = "thumbv7neon",
47+
target_arch = "tummbv8",
48+
target_arch = "thumbv8m",
49+
target_arch = "thumbv8m.main"))] {
50+
pub type c_char = u8;
51+
pub type wchar_t = u32;
52+
} else if #[cfg(any(target_arch = "i386",
53+
target_arch = "i586",
54+
target_arch = "i686",
55+
target_arch = "x86",
56+
target_arch = "x86_64",
57+
target_arch = "mips",
58+
target_arch = "mips64",
59+
target_arch = "mips64el",
60+
target_arch = "mipsel",
61+
target_arch = "nvptx",
62+
target_arch = "nvptx64",
63+
target_arch = "sparc64",
64+
target_arch = "sparcv9",
65+
target_arch = "riscv64",
66+
target_arch = "riscv32",
67+
target_arch = "riscv32imac",
68+
target_arch = "riscv32imc"))] {
69+
pub type c_char = i8;
70+
pub type wchar_t = i32;
71+
}
8272
}
8373

8474
// On all platforms but Windows, longs are the same size as a pointer.
85-
pub use self::long::*;
86-
#[cfg(target_pointer_width = "64")]
87-
mod long {
88-
pub type c_long = i64;
89-
pub type c_ulong = u64;
90-
}
91-
92-
#[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
93-
mod long {
94-
pub type c_long = i32;
95-
pub type c_ulong = u32;
75+
cfg_if! {
76+
if #[cfg(target_pointer_width = "64")] {
77+
pub type c_long = i64;
78+
pub type c_ulong = u64;
79+
} else {
80+
pub type c_long = i32;
81+
pub type c_ulong = u32;
82+
}
9683
}
9784

9885
// POSIX specifications make no guarantees that off_t == long int, but this is
9986
// what GNU and others always do.
10087
pub type off_t = ::c_long;
88+
89+
// These follow directly from the definition of c_int
90+
pub const INT_MIN: c_int = -2147483648;
91+
pub const INT_MAX: c_int = 2147483647;

src/redox/mod.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,17 @@ extern {
248248
pub fn fflush(file: *mut FILE) -> ::c_int;
249249
pub fn fclose(file: *mut FILE) -> ::c_int;
250250
pub fn remove(filename: *const ::c_char) -> ::c_int;
251-
pub fn rename(oldname: *const ::c_char, newname: *const ::c_char) -> ::c_int;
251+
pub fn rename(oldname: *const ::c_char,
252+
newname: *const ::c_char) -> ::c_int;
252253
pub fn tmpfile() -> *mut FILE;
253254
pub fn setvbuf(stream: *mut FILE, buffer: *mut ::c_char, mode: ::c_int,
254255
size: ::size_t) -> ::c_int;
255256
pub fn setbuf(stream: *mut FILE, buf: *mut ::c_char);
256257
pub fn getchar() -> ::c_int;
257258
pub fn putchar(c: ::c_int) -> ::c_int;
258259
pub fn fgetc(stream: *mut FILE) -> ::c_int;
259-
pub fn fgets(buf: *mut ::c_char, n: ::c_int, stream: *mut FILE) -> *mut ::c_char;
260+
pub fn fgets(buf: *mut ::c_char, n: ::c_int,
261+
stream: *mut FILE) -> *mut ::c_char;
260262
pub fn fputc(c: ::c_int, stream: *mut FILE) -> ::c_int;
261263
pub fn fputs(s: *const ::c_char, stream: *mut FILE) -> ::c_int;
262264
pub fn puts(s: *const ::c_char) -> ::c_int;
@@ -265,7 +267,8 @@ extern {
265267
stream: *mut FILE) -> ::size_t;
266268
pub fn fwrite(ptr: *const ::c_void, size: ::size_t, nobj: ::size_t,
267269
stream: *mut FILE) -> ::size_t;
268-
pub fn fseek(stream: *mut FILE, offset: ::c_long, whence: ::c_int) -> ::c_int;
270+
pub fn fseek(stream: *mut FILE, offset: ::c_long,
271+
whence: ::c_int) -> ::c_int;
269272
pub fn ftell(stream: *mut FILE) -> ::c_long;
270273
pub fn rewind(stream: *mut FILE);
271274
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> ::c_int;
@@ -307,26 +310,31 @@ extern {
307310
pub fn strdup(cs: *const ::c_char) -> *mut ::c_char;
308311
pub fn strpbrk(cs: *const ::c_char, ct: *const ::c_char) -> *mut ::c_char;
309312
pub fn strstr(cs: *const ::c_char, ct: *const ::c_char) -> *mut ::c_char;
310-
pub fn strcasestr(cs: *const ::c_char, ct: *const ::c_char) -> *mut ::c_char;
313+
pub fn strcasestr(cs: *const ::c_char,
314+
ct: *const ::c_char) -> *mut ::c_char;
311315
pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
312316
pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char,
313317
n: ::size_t) -> ::c_int;
314318
pub fn strlen(cs: *const ::c_char) -> ::size_t;
315319
pub fn strnlen(cs: *const ::c_char, maxlen: ::size_t) -> ::size_t;
316320
pub fn strerror(n: ::c_int) -> *mut ::c_char;
317321
pub fn strtok(s: *mut ::c_char, t: *const ::c_char) -> *mut ::c_char;
318-
pub fn strxfrm(s: *mut ::c_char, ct: *const ::c_char, n: ::size_t) -> ::size_t;
322+
pub fn strxfrm(s: *mut ::c_char, ct: *const ::c_char,
323+
n: ::size_t) -> ::size_t;
319324
pub fn wcslen(buf: *const wchar_t) -> ::size_t;
320325
pub fn wcstombs(dest: *mut ::c_char, src: *const wchar_t,
321326
n: ::size_t) -> ::size_t;
322327

323-
pub fn memchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
324-
pub fn memcmp(cx: *const ::c_void, ct: *const ::c_void, n: ::size_t) -> ::c_int;
328+
pub fn memchr(cx: *const ::c_void, c: ::c_int,
329+
n: ::size_t) -> *mut ::c_void;
330+
pub fn memcmp(cx: *const ::c_void, ct: *const ::c_void,
331+
n: ::size_t) -> ::c_int;
325332
pub fn memcpy(dest: *mut ::c_void, src: *const ::c_void,
326333
n: ::size_t) -> *mut ::c_void;
327334
pub fn memmove(dest: *mut ::c_void, src: *const ::c_void,
328335
n: ::size_t) -> *mut ::c_void;
329-
pub fn memset(dest: *mut ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
336+
pub fn memset(dest: *mut ::c_void, c: ::c_int,
337+
n: ::size_t) -> *mut ::c_void;
330338

331339
pub fn abs(i: ::c_int) -> ::c_int;
332340
pub fn atof(s: *const ::c_char) -> ::c_double;
@@ -355,8 +363,8 @@ extern {
355363
pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
356364
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
357365
pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t;
358-
pub fn setenv(name: *const ::c_char, val: *const ::c_char, overwrite: ::c_int)
359-
-> ::c_int;
366+
pub fn setenv(name: *const ::c_char, val: *const ::c_char,
367+
overwrite: ::c_int) -> ::c_int;
360368
pub fn unsetenv(name: *const ::c_char) -> ::c_int;
361369
pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
362370
-> ::ssize_t;

0 commit comments

Comments
 (0)