Skip to content

Commit

Permalink
c: upgrade to c23
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler569 committed Apr 9, 2024
1 parent 3ead464 commit 65336af
Show file tree
Hide file tree
Showing 192 changed files with 648 additions and 773 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ project(nightingale C ASM CXX)
unset(CMAKE_SYSROOT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/sysroot)
set(CMAKE_SYSROOT ${CMAKE_BINARY_DIR}/sysroot)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_C_STANDARD 23)

execute_process(
COMMAND git describe --tags
Expand Down Expand Up @@ -54,8 +53,6 @@ add_compile_options(
-Wno-sign-compare
-Wno-address-of-packed-member
-Wno-deprecated-non-prototype
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
)

if ($ENV{ENABLE_WERROR})
Expand Down
1 change: 0 additions & 1 deletion include/arpa/inet.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ static inline uint16_t ntohs(uint16_t netshort) {
}

END_DECLS

1 change: 0 additions & 1 deletion include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@
#define assert(...)
#define _UNREACHABLE()
#endif // NDEBUG

1 change: 0 additions & 1 deletion include/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ int toupper(int c);
int tolower(int c);

END_DECLS

1 change: 0 additions & 1 deletion include/dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ ssize_t readdir(int fd, struct dirent *buf, size_t size);
#endif

END_DECLS

2 changes: 0 additions & 2 deletions include/dlfcn.h
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#pragma once


1 change: 0 additions & 1 deletion include/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,3 @@ void limine_load_kernel_elf(void *ptr, size_t len);
#endif

END_DECLS

1 change: 0 additions & 1 deletion include/endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
#define BIG_ENDIAN 1
#define LITTLE_ENDIAN 2
#define BYTE_ORDER LITTLE_ENDIAN

1 change: 0 additions & 1 deletion include/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ char *strerror(int errno);
#endif // __kernel__

END_DECLS

1 change: 0 additions & 1 deletion include/fcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ int openat(int atfd, const char *filename, int flags, ...);
// int open(const char *filename, int flags, int mode);

END_DECLS

1 change: 0 additions & 1 deletion include/internals/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ typedef long double __double_t;
#endif

#endif

1 change: 0 additions & 1 deletion include/internals/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ typedef int8_t __int8_t;
typedef int16_t __int16_t;
typedef int32_t __int32_t;
typedef int64_t __int64_t;

1 change: 0 additions & 1 deletion include/inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@
#define PRIo64 "%lo"
#define PRIoMAX "%zo"
#define PRIoPTR "%zo"

1 change: 0 additions & 1 deletion include/limine.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,3 @@ struct limine_dtb_request {
#endif

#endif

1 change: 0 additions & 1 deletion include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,3 @@ static inline list_node *list_pop_front(list_node *head) {
}

END_DECLS

1 change: 0 additions & 1 deletion include/locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ struct lconv *localeconv(void);
char *setlocale(int category, const char *locale);

END_DECLS

1 change: 0 additions & 1 deletion include/net/eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ struct eth_hdr {
#define ETH_TYPE_IP 0x0800

END_DECLS

1 change: 0 additions & 1 deletion include/net/ip4.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ struct ip4_hdr {
#define IP4_PROTOCOL_UDP 17

END_DECLS

1 change: 0 additions & 1 deletion include/net/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ struct udp_hdr {
};

END_DECLS

1 change: 0 additions & 1 deletion include/ng/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ void arch_ap_setup(int cpu);
void arch_ap_init(void);

END_DECLS

1 change: 0 additions & 1 deletion include/ng/commandline.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ void init_command_line(void);
const char *get_kernel_argument(const char *key);

END_DECLS

1 change: 0 additions & 1 deletion include/ng/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@
__auto_type _p = (place); \
(_v + _p - 1) & ~(_p - 1); \
})

1 change: 0 additions & 1 deletion include/ng/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
#endif

#include <nightingale.h>

1 change: 0 additions & 1 deletion include/ng/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ void hexdump(const void *data, size_t len, uintptr_t base_address);
__NOINLINE void break_point(void);

END_DECLS

1 change: 0 additions & 1 deletion include/ng/dmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ void *dmgr_set(struct dmgr *d, int handle, void *newptr);
void *dmgr_drop(struct dmgr *d, int handle);

END_DECLS

1 change: 0 additions & 1 deletion include/ng/drv/pci_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,3 @@ class pci_device {

nx::optional<pci_address> pci_find_device(
uint16_t vendor_id, uint16_t device_id);

1 change: 0 additions & 1 deletion include/ng/drv/rtl8139.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ class rtl8139 : public pci_device {
void send_packet(const void *data, size_t len);
void recv_packet(void *data, size_t len);
};

1 change: 0 additions & 1 deletion include/ng/event_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ void log_event(enum event_type type, const char *message, ...);
#endif

END_DECLS

3 changes: 1 addition & 2 deletions include/ng/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <ng/fs/dentry.h>
#include <ng/fs/file.h>
#include <ng/fs/file_system.h>
#include <ng/fs/inode.h>
#include <ng/fs/proc.h>
#include <ng/fs/vnode.h>
#include <ng/ringbuf.h>
#include <ng/sync.h>
#include <ng/syscall.h>
Expand All @@ -20,4 +20,3 @@
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <sys/types.h>

2 changes: 1 addition & 1 deletion include/ng/fs/char_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ enum simple_char_devices {
FS_DEV_INC,
};

extern struct file_operations *char_drivers[256];
extern struct file_ops *char_drivers[256];

END_DECLS
19 changes: 9 additions & 10 deletions include/ng/fs/dentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

BEGIN_DECLS

struct dentry_operations {
struct dentry_ops {
char unused;
};

Expand All @@ -17,8 +17,8 @@ enum dentry_flags {
};

struct dentry {
const struct dentry_operations *ops;
struct inode *inode;
const struct dentry_ops *ops;
struct vnode *vnode;
struct dentry *parent;
const char *name;
enum dentry_flags flags;
Expand All @@ -35,11 +35,11 @@ struct dentry {

extern struct dentry *global_root_dentry;

inline struct inode *dentry_inode(struct dentry *dentry) {
inline struct vnode *dentry_vnode(struct dentry *dentry) {
if (dentry->mounted_file_system) {
return dentry->mounted_file_system->root->inode;
return dentry->mounted_file_system->root->vnode;
} else {
return dentry->inode;
return dentry->vnode;
}
}

Expand All @@ -54,11 +54,11 @@ inline struct file_system *dentry_file_system(struct dentry *dentry) {
struct dentry *new_dentry();

struct dentry *add_child(
struct dentry *dentry, const char *name, struct inode *inode);
struct dentry *dentry, const char *name, struct vnode *vnode);
struct dentry *find_child(struct dentry *, const char *);
struct dentry *unlink_dentry(struct dentry *dentry);
int attach_inode(struct dentry *, struct inode *);
void detach_inode(struct dentry *);
int attach_vnode(struct dentry *, struct vnode *);
void detach_vnode(struct dentry *);
void maybe_delete_dentry(struct dentry *);

struct dentry *resolve_path(const char *path);
Expand All @@ -69,4 +69,3 @@ struct dentry *resolve_path_from(
int pathname(struct dentry *dentry, char *buffer, size_t len);

END_DECLS

18 changes: 9 additions & 9 deletions include/ng/fs/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

BEGIN_DECLS

struct file_operations {
struct file_ops {
ssize_t (*read)(struct file *, char *buffer, size_t len);
ssize_t (*write)(struct file *, const char *buffer, size_t len);
int (*ioctl)(struct file *, int request, void *argp);
off_t (*seek)(struct file *, off_t offset, int whence);
ssize_t (*getdents)(struct file *, struct dirent *, size_t);
};

extern struct file_operations default_file_ops;
extern struct file_ops default_file_ops;

struct file {
#define FILE_MAGIC 47841728
long magic;
struct dentry *dentry;
struct inode *inode;
const struct file_operations *ops;
struct vnode *vnode;
const struct file_ops *ops;
enum open_flags flags;

off_t offset;
Expand All @@ -44,17 +44,17 @@ ssize_t default_write(struct file *, const char *, size_t);

bool read_mode(struct file *file);
bool write_mode(struct file *file);
bool has_permission(struct inode *inode, int flags);
bool read_permission(struct inode *inode);
bool write_permission(struct inode *inode);
bool execute_permission(struct inode *inode);
bool has_permission(struct vnode *vnode, int flags);
bool read_permission(struct vnode *vnode);
bool write_permission(struct vnode *vnode);
bool execute_permission(struct vnode *vnode);

ssize_t read_file(struct file *file, char *buffer, size_t len);
ssize_t write_file(struct file *file, const char *buffer, size_t len);
int ioctl_file(struct file *file, int request, void *argp);
off_t seek_file(struct file *file, off_t offset, int whence);
ssize_t getdents_file(struct file *file, struct dirent *buf, size_t len);
ssize_t readlink_inode(struct inode *inode, char *buffer, size_t len);
ssize_t readlink_vnode(struct vnode *vnode, char *buffer, size_t len);

struct process;
struct file *clone_file(struct file *file);
Expand Down
29 changes: 14 additions & 15 deletions include/ng/fs/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,38 @@ BEGIN_DECLS
extern struct file_system *initfs_file_system;
extern struct file_system *proc_file_system;
extern list mounted_file_systems;
extern struct file_system_operations default_file_system_ops;
extern struct file_system_ops default_file_system_ops;

struct file_system_operations {
struct inode *(*new_inode)(struct file_system *);
struct inode *(*get_inode)(struct file_system *, long);
void (*destroy_inode)(struct inode *);
struct file_system_ops {
struct vnode *(*new_vnode)(struct file_system *);
struct vnode *(*get_vnode)(struct file_system *, long);
void (*destroy_vnode)(struct vnode *);

int (*mount)(struct file_system *, struct dentry *);
};

struct file_system_type {
struct file_system_operations *ops;
struct file_system_ops *ops;
};

struct file_system {
struct file_system_operations *ops;
struct file_system_ops *ops;
struct dentry *root;

int next_inode_number; // for in-memory filesystems
int next_vnode_number; // for in-memory filesystems
list_node node; // mounted_file_systems->
list inodes; // inode->fs_inode
list vnodes; // vnode->fs_vnode
};

// The _notime version of new_inode is intended for file systems that
// save the mtime, atime, and ctime seperately. By default, new_inode
// The _notime version of new_vnode is intended for file systems that
// save the mtime, atime, and ctime seperately. By default, new_vnode
// populates these with the current time, so if that's not needed,
// _notime is an optimization.
struct inode *new_inode_notime(struct file_system *file_system, int mode);
struct inode *new_inode(struct file_system *, int mode);
// void destroy_inode(struct inode *);
struct vnode *new_vnode_notime(struct file_system *file_system, int mode);
struct vnode *new_vnode(struct file_system *, int mode);
// void destroy_vnode(struct vnode *);
// void mount(struct file_system *, struct dentry *);

void mount_file_system(struct file_system *file_system, struct dentry *dentry);

END_DECLS

1 change: 0 additions & 1 deletion include/ng/fs/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ void fs_init(void *);
void load_initfs(void *);

END_DECLS

3 changes: 1 addition & 2 deletions include/ng/fs/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

BEGIN_DECLS

struct inode *new_pipe(void);
struct vnode *new_pipe(void);

END_DECLS

3 changes: 1 addition & 2 deletions include/ng/fs/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ BEGIN_DECLS
void make_proc_file(
const char *name, void (*generate)(struct file *, void *arg), void *arg);

struct inode *new_proc_inode(
struct vnode *new_proc_vnode(
int mode, void (*generate)(struct file *, void *arg), void *arg);

void proc_sprintf(struct file *, const char *fmt, ...) __PRINTF(2, 3);

END_DECLS

16 changes: 8 additions & 8 deletions include/ng/fs/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

BEGIN_DECLS

struct socket_operations {
int (*bind)(struct inode *inode, struct sockaddr *addr, socklen_t addrlen);
int (*listen)(struct inode *inode, int backlog);
struct socket_ops {
int (*bind)(struct vnode *vnode, struct sockaddr *addr, socklen_t addrlen);
int (*listen)(struct vnode *vnode, int backlog);
int (*accept)(
struct inode *inode, struct sockaddr *addr, socklen_t *addrlen);
struct vnode *vnode, struct sockaddr *addr, socklen_t *addrlen);
int (*connect)(
struct inode *inode, struct sockaddr *addr, socklen_t addrlen);
int (*send)(struct inode *inode, const void *buf, size_t len, int flags);
int (*recv)(struct inode *inode, void *buf, size_t len, int flags);
struct vnode *vnode, struct sockaddr *addr, socklen_t addrlen);
int (*send)(struct vnode *vnode, const void *buf, size_t len, int flags);
int (*recv)(struct vnode *vnode, void *buf, size_t len, int flags);
};

struct inode *new_socket(void);
struct vnode *new_socket(void);

END_DECLS
1 change: 0 additions & 1 deletion include/ng/fs/tmpfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ BEGIN_DECLS
struct file_system *new_tmpfs_file_system(void);

END_DECLS

Loading

0 comments on commit 65336af

Please sign in to comment.