Skip to content

Commit 37f676f

Browse files
committed
Auto merge of #1473 - Wind-River:master, r=gnzlbg
Some update for vxWorks This is to address issues: #1469 and rust-random/getrandom#86 (comment) What have been changed in this PR: 1. adding randBytes(), randABytes(), randUBytes(), randSecure() and taskDelay() 2. change armv7-wrs-vxworks to armv7-wrs-vxworks-eabihf 3. code cleanup
2 parents 50fbf0c + e43e863 commit 37f676f

File tree

1 file changed

+10
-155
lines changed

1 file changed

+10
-155
lines changed

src/vxworks/mod.rs

+10-155
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Hacking together the definitions for VxWorks Bindings
1+
//! Interface to VxWorks C library
2+
23
use core::mem::size_of;
34
use core::ptr::null_mut;
45

@@ -188,7 +189,7 @@ s! {
188189
pub __ss_pad2 : [::c_char; 32],
189190
pub __ss_pad3 : [::c_char; 32],
190191
pub __ss_pad4 : [::c_char; 32],
191-
pub __ss_pad5 : [::c_char; 32],
192+
pub __ss_pad5 : [::c_char; _SS_PAD2SIZE - 96],
192193
}
193194
pub struct iovec {
194195
pub iov_base: *mut ::c_void,
@@ -963,15 +964,7 @@ extern {
963964
pub fn isxdigit(c: c_int) -> c_int;
964965
pub fn tolower(c: c_int) -> c_int;
965966
pub fn toupper(c: c_int) -> c_int;
966-
#[cfg_attr(
967-
all(target_os = "macos", target_arch = "x86"),
968-
link_name = "fopen$UNIX2003"
969-
)]
970967
pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
971-
#[cfg_attr(
972-
all(target_os = "macos", target_arch = "x86"),
973-
link_name = "freopen$UNIX2003"
974-
)]
975968
pub fn freopen(
976969
filename: *const c_char,
977970
mode: *const c_char,
@@ -995,10 +988,6 @@ extern {
995988
pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
996989
-> *mut c_char;
997990
pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
998-
#[cfg_attr(
999-
all(target_os = "macos", target_arch = "x86"),
1000-
link_name = "fputs$UNIX2003"
1001-
)]
1002991
pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
1003992
pub fn puts(s: *const c_char) -> c_int;
1004993
pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
@@ -1008,10 +997,6 @@ extern {
1008997
nobj: size_t,
1009998
stream: *mut FILE,
1010999
) -> size_t;
1011-
#[cfg_attr(
1012-
all(target_os = "macos", target_arch = "x86"),
1013-
link_name = "fwrite$UNIX2003"
1014-
)]
10151000
pub fn fwrite(
10161001
ptr: *const c_void,
10171002
size: size_t,
@@ -1021,18 +1006,12 @@ extern {
10211006
pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
10221007
pub fn ftell(stream: *mut FILE) -> c_long;
10231008
pub fn rewind(stream: *mut FILE);
1024-
#[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")]
10251009
pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
1026-
#[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")]
10271010
pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
10281011
pub fn feof(stream: *mut FILE) -> c_int;
10291012
pub fn ferror(stream: *mut FILE) -> c_int;
10301013
pub fn perror(s: *const c_char);
10311014
pub fn atoi(s: *const c_char) -> c_int;
1032-
#[cfg_attr(
1033-
all(target_os = "macos", target_arch = "x86"),
1034-
link_name = "strtod$UNIX2003"
1035-
)]
10361015
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
10371016
pub fn strtol(
10381017
s: *const c_char,
@@ -1052,10 +1031,6 @@ extern {
10521031
pub fn exit(status: c_int) -> !;
10531032
// pub fn _exit(status: c_int) -> !;
10541033
pub fn atexit(cb: extern fn()) -> c_int;
1055-
#[cfg_attr(
1056-
all(target_os = "macos", target_arch = "x86"),
1057-
link_name = "system$UNIX2003"
1058-
)]
10591034
pub fn system(s: *const c_char) -> c_int;
10601035
pub fn getenv(s: *const c_char) -> *mut c_char;
10611036

@@ -1089,10 +1064,6 @@ extern {
10891064
) -> c_int;
10901065
pub fn strlen(cs: *const c_char) -> size_t;
10911066
pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
1092-
#[cfg_attr(
1093-
all(target_os = "macos", target_arch = "x86"),
1094-
link_name = "strerror$UNIX2003"
1095-
)]
10961067
pub fn strerror(n: c_int) -> *mut c_char;
10971068
pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
10981069
pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
@@ -1119,9 +1090,7 @@ extern {
11191090
}
11201091

11211092
extern {
1122-
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
11231093
pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
1124-
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
11251094
pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
11261095

11271096
pub fn fprintf(
@@ -1147,29 +1116,12 @@ extern {
11471116
-> ::c_int;
11481117
pub fn getchar_unlocked() -> ::c_int;
11491118
pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
1150-
11511119
pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
1152-
11531120
pub fn pclose(stream: *mut ::FILE) -> ::c_int;
1154-
#[cfg_attr(
1155-
all(target_os = "macos", target_arch = "x86"),
1156-
link_name = "fdopen$UNIX2003"
1157-
)]
11581121
pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
11591122
pub fn fileno(stream: *mut ::FILE) -> ::c_int;
1160-
1161-
#[cfg_attr(
1162-
all(target_os = "macos", target_arch = "x86"),
1163-
link_name = "open$UNIX2003"
1164-
)]
1165-
#[cfg_attr(
1166-
all(target_os = "macos", target_arch = "x86"),
1167-
link_name = "creat$UNIX2003"
1168-
)]
11691123
pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
1170-
11711124
pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
1172-
11731125
pub fn rewinddir(dirp: *mut ::DIR);
11741126

11751127
pub fn openat(
@@ -1192,8 +1144,6 @@ extern {
11921144
group: ::gid_t,
11931145
flags: ::c_int,
11941146
) -> ::c_int;
1195-
#[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
1196-
#[cfg_attr(target_os = "freebsd", link_name = "fstatat@FBSD_1.1")]
11971147
pub fn fstatat(
11981148
dirfd: ::c_int,
11991149
pathname: *const ::c_char,
@@ -1234,10 +1184,6 @@ extern {
12341184
pub fn alarm(seconds: ::c_uint) -> ::c_uint;
12351185
pub fn fchdir(dirfd: ::c_int) -> ::c_int;
12361186
pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
1237-
#[cfg_attr(
1238-
all(target_os = "macos", target_arch = "x86"),
1239-
link_name = "lchown$UNIX2003"
1240-
)]
12411187
pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
12421188
pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int;
12431189
pub fn execle(
@@ -1282,39 +1228,13 @@ extern {
12821228
pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
12831229
pub fn ttyname(fd: ::c_int) -> *mut c_char;
12841230
pub fn wait(status: *mut ::c_int) -> pid_t;
1285-
/*
1286-
pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
1287-
offset: off_t) -> ::ssize_t;
1288-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1289-
link_name = "pwrite$UNIX2003")]
1290-
pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
1291-
offset: off_t) -> ::ssize_t;
1292-
*/
12931231
pub fn umask(mask: mode_t) -> mode_t;
1294-
1295-
// #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
1296-
// pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
1297-
1298-
/*
1299-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1300-
link_name = "kill$UNIX2003")]
1301-
pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
1302-
*/
1303-
#[cfg_attr(
1304-
all(target_os = "macos", target_arch = "x86"),
1305-
link_name = "killpg$UNIX2003"
1306-
)]
13071232
pub fn killpg(pgrp: pid_t, sig: ::c_int) -> ::c_int;
1308-
13091233
pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
13101234
pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
13111235
pub fn mlockall(flags: ::c_int) -> ::c_int;
13121236
pub fn munlockall() -> ::c_int;
13131237

1314-
#[cfg_attr(
1315-
all(target_os = "macos", target_arch = "x86"),
1316-
link_name = "mmap$UNIX2003"
1317-
)]
13181238
pub fn mmap(
13191239
addr: *mut ::c_void,
13201240
len: ::size_t,
@@ -1323,10 +1243,6 @@ extern {
13231243
fd: ::c_int,
13241244
offset: off_t,
13251245
) -> *mut ::c_void;
1326-
#[cfg_attr(
1327-
all(target_os = "macos", target_arch = "x86"),
1328-
link_name = "munmap$UNIX2003"
1329-
)]
13301246
pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
13311247

13321248
pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
@@ -1337,28 +1253,10 @@ extern {
13371253

13381254
pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
13391255

1340-
#[cfg_attr(
1341-
all(target_os = "macos", target_arch = "x86"),
1342-
link_name = "getrlimit$UNIX2003"
1343-
)]
13441256
pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
1345-
#[cfg_attr(
1346-
all(target_os = "macos", target_arch = "x86"),
1347-
link_name = "setrlimit$UNIX2003"
1348-
)]
13491257
pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
1350-
// #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
1351-
// pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
1352-
1353-
/*
1354-
#[cfg_attr(any(target_os = "macos", target_os = "ios"),
1355-
link_name = "realpath$DARWIN_EXTSN")]
1356-
pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
1357-
-> *mut ::c_char;
1358-
*/
13591258
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
13601259

1361-
#[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")]
13621260
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
13631261
pub fn pthread_exit(value: *mut ::c_void);
13641262
pub fn pthread_attr_setdetachstate(
@@ -1378,7 +1276,6 @@ extern {
13781276
oldact: *mut sigaction,
13791277
) -> ::c_int;
13801278

1381-
#[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
13821279
pub fn utimes(
13831280
filename: *const ::c_char,
13841281
times: *const ::timeval,
@@ -1391,67 +1288,27 @@ extern {
13911288
) -> *mut ::c_void;
13921289
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
13931290
pub fn res_init() -> ::c_int;
1394-
/*
1395-
#[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
1396-
pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1397-
#[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
1398-
pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1399-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1400-
link_name = "mktime$UNIX2003")]
1401-
#[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
1402-
pub fn mktime(tm: *mut tm) -> time_t;
1403-
#[cfg_attr(target_os = "netbsd", link_name = "__time50")]
1404-
pub fn time(time: *mut time_t) -> time_t;
1405-
#[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
1406-
pub fn gmtime(time_p: *const time_t) -> *mut tm;
1407-
#[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
1408-
pub fn localtime(time_p: *const time_t) -> *mut tm;
1409-
*/
1410-
#[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
14111291
pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
14121292

1413-
#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
1414-
#[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")]
14151293
pub fn mknod(
14161294
pathname: *const ::c_char,
14171295
mode: ::mode_t,
14181296
dev: ::dev_t,
14191297
) -> ::c_int;
14201298
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
1421-
// pub fn getservbyname(name: *const ::c_char,
1422-
// proto: *const ::c_char) -> *mut servent;
1423-
// pub fn getprotobyname(name: *const ::c_char) -> *mut protoent;
1424-
// pub fn getprotobynumber(proto: ::c_int) -> *mut protoent;
14251299
pub fn chroot(name: *const ::c_char) -> ::c_int;
1426-
#[cfg_attr(
1427-
all(target_os = "macos", target_arch = "x86"),
1428-
link_name = "usleep$UNIX2003"
1429-
)]
14301300
pub fn usleep(secs: ::c_uint) -> ::c_int;
1431-
#[cfg_attr(
1432-
all(target_os = "macos", target_arch = "x86"),
1433-
link_name = "putenv$UNIX2003"
1434-
)]
14351301
pub fn putenv(string: *mut c_char) -> ::c_int;
1436-
#[cfg_attr(target_os = "netbsd", link_name = "__select50")]
1437-
// pub fn select(nfds: ::c_int,
1438-
// readfs: *mut fd_set,
1439-
// writefds: *mut fd_set,
1440-
// errorfds: *mut fd_set,
1441-
// timeout: *mut timeval) -> ::c_int;
1442-
#[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
14431302
pub fn setlocale(
14441303
category: ::c_int,
14451304
locale: *const ::c_char,
14461305
) -> *mut ::c_char;
1447-
// pub fn localeconv() -> *mut lconv;
14481306

14491307
pub fn sigprocmask(
14501308
how: ::c_int,
14511309
set: *const sigset_t,
14521310
oldset: *mut sigset_t,
14531311
) -> ::c_int;
1454-
#[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
14551312
pub fn sigpending(set: *mut sigset_t) -> ::c_int;
14561313

14571314
pub fn getsid(pid: pid_t) -> pid_t;
@@ -1464,10 +1321,6 @@ extern {
14641321
whence: ::c_int,
14651322
) -> ::c_int;
14661323
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
1467-
#[cfg_attr(
1468-
all(target_os = "macos", target_arch = "x86"),
1469-
link_name = "tcdrain$UNIX2003"
1470-
)]
14711324
pub fn tcdrain(fd: ::c_int) -> ::c_int;
14721325
pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
14731326
pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
@@ -1481,12 +1334,7 @@ extern {
14811334
pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
14821335
pub fn closelog();
14831336
pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
1484-
#[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")]
14851337
pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
1486-
#[cfg_attr(
1487-
all(target_os = "macos", target_arch = "x86"),
1488-
link_name = "nice$UNIX2003"
1489-
)]
14901338
pub fn nice(incr: ::c_int) -> ::c_int;
14911339

14921340
pub fn grantpt(fd: ::c_int) -> ::c_int;
@@ -2141,6 +1989,7 @@ extern {
21411989
pub fn raise(__signo: ::c_int) -> ::c_int;
21421990
// taskLibCommon.h
21431991
pub fn taskIdSelf() -> ::TASK_ID;
1992+
pub fn taskDelay(ticks: ::_Vx_ticks_t) -> ::c_int;
21441993

21451994
// rtpLibCommon.h
21461995
pub fn rtpInfoGet(rtpId: ::RTP_ID, rtpStruct: *mut ::RTP_DESC) -> ::c_int;
@@ -2167,6 +2016,12 @@ extern {
21672016
iov: *const ::iovec,
21682017
iovcnt: ::c_int,
21692018
) -> ::ssize_t;
2019+
2020+
// randomNumGen.h
2021+
pub fn randBytes(buf: *mut c_uchar, length: c_int) -> c_int;
2022+
pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int;
2023+
pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int;
2024+
pub fn randSecure() -> c_int;
21702025
}
21712026

21722027
pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int {

0 commit comments

Comments
 (0)