miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Toggle main menu visibility
Loading...
Searching...
No Matches
libc.h
Go to the documentation of this file.
1
// MIT License
2
//
3
// Copyright (c) 2026 Christian Spoo
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef _USER_LIBC_H_
24
#define _USER_LIBC_H_
25
26
typedef
unsigned
long
size_t
;
27
typedef
long
ssize_t
;
28
typedef
long
pid_t
;
29
30
/* Syscall wrappers implemented in syscall.asm */
31
ssize_t
write
(
int
fd
,
const
void
*buf,
size_t
count);
32
ssize_t
read
(
int
fd
,
void
*buf,
size_t
count);
33
int
open
(
const
char
*path);
/* O_RDONLY, no flags needed for kernel */
34
int
close
(
int
fd
);
35
void
exit
(
int
code)
__attribute__
((noreturn));
36
pid_t
fork
(
void
);
37
int
exec
(
const
char
*path);
/* simplified: no argv -- shell passes command name only */
38
39
/* wait() wraps _libc_wait because 'wait' is a reserved mnemonic in NASM */
40
pid_t
_libc_wait
(
int
*status);
41
static
inline
pid_t
wait
(
int
*status) {
return
_libc_wait
(status); }
42
43
/* waitpid(): wait for specific child pid. Use this instead of wait() to avoid
44
* passing a status pointer where the kernel expects a child TID. */
45
pid_t
waitpid
(
pid_t
pid,
int
*status,
int
options);
46
47
#endif
/* _USER_LIBC_H_ */
ssize_t
long ssize_t
Definition
cc.h:39
open
int open(const char *path)
exit
void exit(int code) __attribute__((noreturn))
Definition
syscalls.c:197
waitpid
pid_t waitpid(pid_t pid, int *status, int options)
Definition
syscalls.c:336
wait
static pid_t wait(int *status)
Definition
libc.h:41
exec
int exec(const char *path)
Definition
syscalls.c:267
fork
pid_t fork(void)
Definition
syscalls.c:263
close
int close(int fd)
Definition
syscalls.c:174
write
ssize_t write(int fd, const void *buf, size_t count)
Definition
syscalls.c:129
read
ssize_t read(int fd, void *buf, size_t count)
Definition
syscalls.c:144
_libc_wait
pid_t _libc_wait(int *status)
Definition
syscalls.c:349
__attribute__
Definition
dirent.h:6
fd
int fd
Definition
syscall_fs.c:0
size_t
uint64_t size_t
Definition
types.h:40
pid_t
int32_t pid_t
Definition
types.h:43
user
libc
libc.h
Generated by
1.18.0