Skip to content

Commit 7035a87

Browse files
committed
Remove duplicate definitions between qurt src/new/qurt
1 parent f6894a4 commit 7035a87

File tree

14 files changed

+241
-630
lines changed

14 files changed

+241
-630
lines changed

src/new/qurt/errno.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `errno.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
// Standard error codes - verified to match QuRT SDK

src/new/qurt/fcntl.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `fcntl.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
// File access modes
@@ -17,10 +18,11 @@ pub const O_TRUNC: c_int = 0x0200;
1718
// File status flags
1819
pub const O_APPEND: c_int = 0x0400;
1920
pub const O_NONBLOCK: c_int = 0x0800;
20-
pub const O_NDELAY: c_int = O_NONBLOCK;
2121
pub const O_SYNC: c_int = 0x1000;
22+
pub const O_FSYNC: c_int = O_SYNC;
23+
pub const O_DSYNC: c_int = 0x1000;
2224

23-
// fcntl commands
25+
// fcntl() commands
2426
pub const F_DUPFD: c_int = 0;
2527
pub const F_GETFD: c_int = 1;
2628
pub const F_SETFD: c_int = 2;
@@ -30,14 +32,15 @@ pub const F_GETLK: c_int = 5;
3032
pub const F_SETLK: c_int = 6;
3133
pub const F_SETLKW: c_int = 7;
3234

33-
// fcntl file descriptor flags
35+
// File descriptor flags
3436
pub const FD_CLOEXEC: c_int = 1;
3537

36-
// flock types
38+
// Lock types for fcntl()
3739
pub const F_RDLCK: c_int = 0;
3840
pub const F_WRLCK: c_int = 1;
3941
pub const F_UNLCK: c_int = 2;
4042

43+
// Functions
4144
extern "C" {
4245
pub fn open(pathname: *const c_char, flags: c_int, ...) -> c_int;
4346
pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;

src/new/qurt/limits.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `limits.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
// Character properties
@@ -10,29 +11,31 @@ pub const SCHAR_MAX: c_schar = 127;
1011
pub const SCHAR_MIN: c_schar = -128;
1112
pub const UCHAR_MAX: c_uchar = 255;
1213

13-
// Integer limits (ILP32 architecture)
14+
// Integer properties
1415
pub const INT_MAX: c_int = 2147483647;
15-
pub const INT_MIN: c_int = -2147483648;
16+
pub const INT_MIN: c_int = (-2147483647 - 1);
1617
pub const UINT_MAX: c_uint = 4294967295;
1718

18-
pub const LONG_MAX: c_long = 2147483647; // 32-bit on Hexagon ILP32
19-
pub const LONG_MIN: c_long = -2147483648; // 32-bit on Hexagon ILP32
20-
pub const ULONG_MAX: c_ulong = 4294967295; // 32-bit on Hexagon ILP32
19+
pub const LONG_MAX: c_long = 2147483647;
20+
pub const LONG_MIN: c_long = (-2147483647 - 1);
21+
pub const ULONG_MAX: c_ulong = 4294967295;
2122

2223
pub const SHRT_MAX: c_short = 32767;
23-
pub const SHRT_MIN: c_short = -32768;
24+
pub const SHRT_MIN: c_short = (-32768);
2425
pub const USHRT_MAX: c_ushort = 65535;
2526

26-
// POSIX limits
27-
pub const PATH_MAX: c_int = 260;
28-
pub const NAME_MAX: c_int = 255;
29-
pub const IOV_MAX: c_int = 16;
27+
// POSIX Limits
3028
pub const ARG_MAX: c_int = 4096;
3129
pub const CHILD_MAX: c_int = 25;
3230
pub const LINK_MAX: c_int = 8;
3331
pub const MAX_CANON: c_int = 255;
3432
pub const MAX_INPUT: c_int = 255;
35-
pub const OPEN_MAX: c_int = 16;
36-
pub const PIPE_BUF: c_int = 4096;
37-
pub const STREAM_MAX: c_int = 8;
38-
pub const TZNAME_MAX: c_int = 6;
33+
pub const NAME_MAX: c_int = 255;
34+
pub const OPEN_MAX: c_int = 20;
35+
pub const PATH_MAX: c_int = 260;
36+
pub const PIPE_BUF: c_int = 512;
37+
pub const STREAM_MAX: c_int = 20;
38+
pub const TZNAME_MAX: c_int = 50;
39+
40+
// Additional limits
41+
pub const IOV_MAX: c_int = 16;

src/new/qurt/mod.rs

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,152 @@
44
//! Headers available via the
55
//! Hexagon SDK: https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK
66
7+
use crate::prelude::*;
8+
9+
// Basic C types for QRT
10+
pub type intptr_t = isize;
11+
pub type uintptr_t = usize;
12+
pub type ptrdiff_t = isize;
13+
pub type size_t = uintptr_t;
14+
pub type ssize_t = intptr_t;
15+
16+
// Process and system types
17+
pub type pid_t = c_int;
18+
pub type uid_t = c_uint;
19+
pub type gid_t = c_uint;
20+
21+
// Time types
22+
pub type time_t = c_longlong;
23+
pub type suseconds_t = c_long;
24+
pub type useconds_t = c_ulong;
25+
pub type clockid_t = c_int;
26+
pub type timer_t = *mut c_void;
27+
28+
// File system types
29+
pub type dev_t = c_ulong;
30+
pub type ino_t = c_ulong;
31+
pub type mode_t = c_uint;
32+
pub type nlink_t = c_uint;
33+
pub type off_t = c_long;
34+
pub type blkcnt_t = c_long;
35+
pub type blksize_t = c_long;
36+
37+
// Thread types based on QuRT pthread implementation
38+
pub type pthread_t = c_uint;
39+
pub type pthread_key_t = c_int;
40+
pub type pthread_once_t = c_int;
41+
pub type pthread_mutex_t = c_uint;
42+
pub type pthread_mutexattr_t = c_uint;
43+
pub type pthread_cond_t = c_uint;
44+
pub type pthread_condattr_t = c_uint;
45+
pub type pthread_attr_t = c_uint;
46+
pub type pthread_rwlock_t = c_uint;
47+
pub type pthread_rwlockattr_t = c_uint;
48+
pub type pthread_spinlock_t = c_uint;
49+
pub type pthread_barrier_t = c_uint;
50+
pub type pthread_barrierattr_t = c_uint;
51+
52+
// Network types
53+
pub type socklen_t = c_uint;
54+
pub type sa_family_t = c_ushort;
55+
pub type in_addr_t = c_uint;
56+
pub type in_port_t = c_ushort;
57+
58+
// File descriptor types
59+
pub type fd_set = c_ulong;
60+
61+
// Standard C library types
62+
extern_ty! {
63+
pub enum FILE {}
64+
}
65+
pub type fpos_t = c_long;
66+
pub type clock_t = c_long;
67+
68+
// POSIX semaphore types
69+
pub type sem_t = c_uint;
70+
71+
// Message queue types
72+
pub type mqd_t = c_int;
73+
74+
// Additional file system types
75+
pub type nfds_t = c_ulong;
76+
77+
// Signal types
78+
pub type sigset_t = c_ulong;
79+
80+
// Variadic argument list type
81+
pub type va_list = *mut c_char;
82+
83+
// Additional missing types
84+
pub type c_schar = i8;
85+
86+
// Division result types
87+
s! {
88+
pub struct div_t {
89+
pub quot: c_int,
90+
pub rem: c_int,
91+
}
92+
93+
pub struct ldiv_t {
94+
pub quot: c_long,
95+
pub rem: c_long,
96+
}
97+
98+
pub struct lldiv_t {
99+
pub quot: c_longlong,
100+
pub rem: c_longlong,
101+
}
102+
103+
pub struct stat {
104+
pub st_dev: dev_t,
105+
pub st_ino: ino_t,
106+
pub st_mode: mode_t,
107+
pub st_nlink: nlink_t,
108+
pub st_uid: uid_t,
109+
pub st_gid: gid_t,
110+
pub st_rdev: dev_t,
111+
pub st_size: off_t,
112+
pub st_blksize: blksize_t,
113+
pub st_blocks: blkcnt_t,
114+
pub st_atime: time_t,
115+
pub st_mtime: time_t,
116+
pub st_ctime: time_t,
117+
}
118+
119+
pub struct tm {
120+
pub tm_sec: c_int,
121+
pub tm_min: c_int,
122+
pub tm_hour: c_int,
123+
pub tm_mday: c_int,
124+
pub tm_mon: c_int,
125+
pub tm_year: c_int,
126+
pub tm_wday: c_int,
127+
pub tm_yday: c_int,
128+
pub tm_isdst: c_int,
129+
}
130+
131+
pub struct timespec {
132+
pub tv_sec: time_t,
133+
pub tv_nsec: c_long,
134+
}
135+
136+
pub struct timeval {
137+
pub tv_sec: time_t,
138+
pub tv_usec: suseconds_t,
139+
}
140+
141+
pub struct itimerspec {
142+
pub it_interval: timespec,
143+
pub it_value: timespec,
144+
}
145+
146+
pub struct sigevent {
147+
pub sigev_notify: c_int,
148+
pub sigev_signo: c_int,
149+
pub sigev_value: c_int,
150+
}
151+
}
152+
7153
pub(crate) mod errno;
8154
pub(crate) mod fcntl;
9155
pub(crate) mod limits;

src/new/qurt/pthread.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
//!
33
//! QuRT provides a subset of POSIX pthread functionality optimized for real-time systems.
44
5+
use super::*;
56
use crate::prelude::*;
7+
use crate::{
8+
cpu_set_t,
9+
pthread_attr_t,
10+
pthread_barrier_t,
11+
pthread_barrierattr_t,
12+
pthread_cond_t,
13+
pthread_condattr_t,
14+
pthread_key_t,
15+
pthread_mutex_t,
16+
pthread_mutexattr_t,
17+
pthread_once_t,
18+
pthread_rwlock_t,
19+
pthread_rwlockattr_t,
20+
pthread_spinlock_t,
21+
pthread_t,
22+
timespec,
23+
};
624

725
// Thread creation attributes
826
pub const PTHREAD_CREATE_JOINABLE: c_int = 0;

src/new/qurt/semaphore.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `semaphore.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
extern "C" {

src/new/qurt/signal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `signal.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
// Standard signal numbers

src/new/qurt/stdio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `stdio.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
// File position constants

src/new/qurt/stdlib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `stdlib.h`
22
3+
use super::*;
34
use crate::prelude::*;
45

56
// Exit status constants

src/new/qurt/sys/stat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Header: `sys/stat.h`
22
3+
use super::super::*;
34
use crate::prelude::*;
45

56
// File type constants for stat.st_mode

0 commit comments

Comments
 (0)