libnix POSIX Features and Extensions
This document lists libnix's POSIX features and extensions that are not part of the C/C++ standards but are available in libnix.
POSIX File Operations
libnix provides POSIX-compliant file operations:
| Function | Header | Description | Status |
|---|---|---|---|
| open | fcntl.h | Open file | Compliant |
| close | unistd.h | Close file | Compliant |
| read | unistd.h | Read from file | Compliant |
| write | unistd.h | Write to file | Compliant |
| lseek | unistd.h | Seek in file | Compliant |
| access | unistd.h | Check file access | Compliant |
| chmod | sys/stat.h | Change file permissions | Compliant |
| chown | unistd.h | Change file owner | Compliant |
| stat | sys/stat.h | Get file status | Compliant |
| fstat | sys/stat.h | Get file status by descriptor | Compliant |
| mkdir | sys/stat.h | Create directory | Compliant |
| rmdir | unistd.h | Remove directory | Compliant |
| unlink | unistd.h | Remove file | Compliant |
| rename | stdio.h | Rename file | Compliant |
| dup | unistd.h | Duplicate file descriptor | Compliant |
| dup2 | unistd.h | Duplicate file descriptor to specific number | Compliant |
| pipe | unistd.h | Create pipe | Compliant |
POSIX Process Management
| Function | Header | Description | Status |
|---|---|---|---|
| fork | unistd.h | Create child process | Compliant |
| execve | unistd.h | Execute program | Compliant |
| execl | unistd.h | Execute program with list of arguments | Compliant |
| execlp | unistd.h | Execute program with PATH search | Compliant |
| execv | unistd.h | Execute program with vector of arguments | Compliant |
| execvp | unistd.h | Execute program with PATH search and vector | Compliant |
| wait | sys/wait.h | Wait for child process | Compliant |
| waitpid | sys/wait.h | Wait for specific child process | Compliant |
| exit | stdlib.h | Exit process | Compliant |
| _exit | unistd.h | Exit process without cleanup | Compliant |
| getpid | unistd.h | Get process ID | Compliant |
| getppid | unistd.h | Get parent process ID | Compliant |
| getuid | unistd.h | Get user ID | Compliant |
| getgid | unistd.h | Get group ID | Compliant |
| setuid | unistd.h | Set user ID | Compliant |
| setgid | unistd.h | Set group ID | Compliant |
POSIX System Information
| Function | Header | Description | Status |
|---|---|---|---|
| uname | sys/utsname.h | Get system information | Compliant |
| sysconf | unistd.h | Get system configuration | Compliant |
| pathconf | unistd.h | Get path configuration | Compliant |
| fpathconf | unistd.h | Get file path configuration | Compliant |
POSIX Memory Management
| Function | Header | Description | Status |
|---|---|---|---|
| brk | unistd.h | Change data segment size | Compliant |
| sbrk | unistd.h | Increment data segment size | Compliant |
| mmap | sys/mman.h | Map memory | Compliant |
| munmap | sys/mman.h | Unmap memory | Compliant |
| mprotect | sys/mman.h | Change memory protection | Compliant |
POSIX Time Functions
| Function | Header | Description | Status |
|---|---|---|---|
| gettimeofday | sys/time.h | Get time of day | Compliant |
| settimeofday | sys/time.h | Set time of day | Compliant |
| select | sys/select.h | Synchronous I/O multiplexing | Compliant |
| sleep | unistd.h | Sleep for seconds | Compliant |
| usleep | unistd.h | Sleep for microseconds | Compliant |
POSIX Environment
| Function | Header | Description | Status |
|---|---|---|---|
| getenv | stdlib.h | Get environment variable | Compliant |
| setenv | stdlib.h | Set environment variable | Compliant |
| unsetenv | stdlib.h | Remove environment variable | Compliant |
| putenv | stdlib.h | Add environment variable | Compliant |
| clearenv | stdlib.h | Clear environment | Compliant |
POSIX Directory Operations
| Function | Header | Description | Status |
|---|---|---|---|
| opendir | dirent.h | Open directory | Compliant |
| readdir | dirent.h | Read directory entry | Compliant |
| closedir | dirent.h | Close directory | Compliant |
| rewinddir | dirent.h | Rewind directory | Compliant |
| seekdir | dirent.h | Seek in directory | Compliant |
| telldir | dirent.h | Tell directory position | Compliant |
POSIX Error Handling
| Function/Macro | Header | Description | Status |
|---|---|---|---|
| errno | errno.h | Error number variable | Compliant |
| perror | stdio.h | Print error message | Compliant |
| strerror | string.h | Get error message string | Compliant |
| EINTR | errno.h | Interrupted system call | Compliant |
| EAGAIN | errno.h | Resource temporarily unavailable | Compliant |
| EINVAL | errno.h | Invalid argument | Compliant |
| ENOENT | errno.h | No such file or directory | Compliant |
| EACCES | errno.h | Permission denied | Compliant |
| EEXIST | errno.h | File exists | Compliant |
| ENOMEM | errno.h | Out of memory | Compliant |
Amiga-Specific Extensions
libnix also provides Amiga-specific extensions:
Auto Library Opening
Similar to SAS/C and DICE, libnix provides automatic library opening when base variables are referenced but not declared.
Amiga OS Integration
- Amiga OS 2.0+ features - Uses OS 2.0 features when available
Summary
libnix provides substantial POSIX support, with the following actual implementations:
**Compliant POSIX Functions:**
- Socket programming - Complete POSIX.1g socket API implementation (via bsdsocket.library)
- File operations - Core POSIX file I/O support (open, close, read, write, lseek, mkdir, rmdir, unlink, readlink, chmod, access, stat, lstat, fstat, utime, utimes, truncate, rename)
- Directory operations - Directory traversal functions (opendir, readdir, closedir, rewinddir)
- Process management - User/group functions (geteuid, getegid, setreuid, setregid, seteuid, setegid, getgroups, setgroups, initgroups, getrusage, times, raise)
- System information - Host and domain functions (gethostname, sethostname, getdomainname)
- Time functions - Basic timing functions (sleep, usleep, gettimeofday)
- Environment functions - Environment variable management (getenv, setenv, unsetenv, putenv)
- Error handling - Error reporting functions (strerror, perror, errno)
**Non-compliant Functions:**
- Process information - Limited process functions (getpid returns Amiga task ID, getppid always returns 1)
- File operations - Some functions are stubs (dup, dup2)
**Missing Functions:**
- Process creation - No fork, exec, wait, or process creation functions
- Memory management - No memory mapping functions (mmap, munmap, etc.)
- Advanced POSIX features - No pipes, process groups, advanced signals, or advanced time functions
- System configuration - No sysconf, pathconf, fpathconf functions
libnix is a comprehensive C standard library with substantial POSIX support, particularly strong in file operations, sockets, and basic system functions. It provides excellent support for porting UNIX/Linux applications to Amiga while maintaining Amiga-specific optimizations.