summaryrefslogtreecommitdiff
path: root/user/include
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-21 16:45:28 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-21 16:45:33 -0400
commitceb9471fed96f907e37a6ba031825c31167a8ff4 (patch)
treed98392e420b4541a6ba926ff4d8b3ebe85734580 /user/include
parentupdate linker scripts (diff)
downloadcomus-ceb9471fed96f907e37a6ba031825c31167a8ff4.tar.gz
comus-ceb9471fed96f907e37a6ba031825c31167a8ff4.tar.bz2
comus-ceb9471fed96f907e37a6ba031825c31167a8ff4.zip
update userland to compile
Diffstat (limited to 'user/include')
l---------[-rw-r--r--]user/include/error.h31
-rw-r--r--user/include/stdio.h45
l---------user/include/syscalls.h1
-rw-r--r--user/include/unistd.h23
4 files changed, 49 insertions, 51 deletions
diff --git a/user/include/error.h b/user/include/error.h
index b9265b4..e62c3b3 100644..120000
--- a/user/include/error.h
+++ b/user/include/error.h
@@ -1,30 +1 @@
-/**
- * @file errno.h
- *
- * @author Freya Murphy <freya@freyacat.org>
- *
- * Error codes.
- */
-
-// public error codes
-#define SUCCESS (0)
-#define E_SUCCESS SUCCESS
-#define E_FAILURE (-1)
-#define E_BAD_PARAM (-2)
-#define E_BAD_FD (-3)
-#define E_NO_CHILDREN (-4)
-#define E_NO_MEMORY (-5)
-#define E_NOT_FOUND (-6)
-#define E_NO_PROCS (-7)
-
-// internal error codes
-#define E_EMPTY_QUEUE (-100)
-#define E_NO_PCBS (-101)
-#define E_NO_PTE (-102)
-#define E_LOAD_LIMIT (-103)
-
-// exit status values
-#define EXIT_SUCCESS (0)
-#define EXIT_FAILURE (-1)
-#define EXIT_KILLED (-101)
-#define EXIT_BAD_SYSCALL (-102)
+../../kernel/include/comus/error.h \ No newline at end of file
diff --git a/user/include/stdio.h b/user/include/stdio.h
index 8a938ab..2e2abf4 100644
--- a/user/include/stdio.h
+++ b/user/include/stdio.h
@@ -27,6 +27,47 @@ extern FILE *stdout;
#define stdout stdout
/**
+ * Get a char from stdin
+ *
+ * @returns the character or EOF on failure
+ */
+extern int getchar(void);
+
+/**
+ * Get a chracter from a stream
+ *
+ * @param stream - the stream to read from
+ * @returns the character or EOF on failure
+ */
+extern int getc(FILE *stream);
+
+/**
+ * Get a chracter from a stream
+ *
+ * @param stream - the stream to read from
+ * @returns the character or EOF on failure
+ */
+extern int fgetc(FILE *stream);
+
+/**
+ * Reads a string from stdin
+ *
+ * @param s - the buffer to read into
+ * @returns s on success, NULL on error or EOF
+ */
+extern char *gets(char *s);
+
+/**
+ * Reads a string from stdin
+ *
+ * @param s - the buffer to read into
+ * @param size - reads at most 1 less then size
+ * @param stream - stream to read from from
+ * @returns s on success, NULL on error or EOF
+ */
+extern char *fgets(char *restrict str, int size, FILE *stream);
+
+/**
* Prints out a char
*
* @param c - the char
@@ -140,7 +181,7 @@ extern int vsnprintf(char *restrict s, size_t maxlen, const char *format,
* @param format - the format string
* @param ... - variable args for the format
*/
-__attribute__((format(printf, 2, 3))) extern void
+__attribute__((format(printf, 2, 3))) extern int
fprintf(FILE *stream, const char *format, ...);
/**
@@ -150,7 +191,7 @@ fprintf(FILE *stream, const char *format, ...);
* @param format - the format string
* @param args - variable arg list for the format
*/
-extern void vfprintf(FILE *stream, const char *format, va_list args);
+extern int vfprintf(FILE *stream, const char *format, va_list args);
/**
* opens a file with a given file name
diff --git a/user/include/syscalls.h b/user/include/syscalls.h
new file mode 120000
index 0000000..0537882
--- /dev/null
+++ b/user/include/syscalls.h
@@ -0,0 +1 @@
+../../kernel/include/comus/syscalls.h \ No newline at end of file
diff --git a/user/include/unistd.h b/user/include/unistd.h
index 1f83abc..a815914 100644
--- a/user/include/unistd.h
+++ b/user/include/unistd.h
@@ -147,33 +147,18 @@ extern int kill(pid_t pid);
extern int sleep(unsigned long ms);
/**
- * Wait for any child to exit
+ * Set the heap break to addr
*
- * @param status - pointer to int32_t into which the child's status is placed,
- * or NULL
- * @return The pid of the terminated child, or an error code
- *
- * Analogous to waitpid(0,status)
- */
-extern int wait(int *status);
-
-/**
- * Spawn a new process running a different program
- *
- * @param prog - program table index of the program to spawn
- * @param args - the command-line argument vector for the process
- * @return the pid of the child, or an error code
- *
- * Analogous to calling fork and exec
+ * @param addr - sets the programs break to addr
+ * @return the previos program break on success, or NULL on failure
*/
-extern int spawn(pid_t prog, char **args);
+extern void *brk(const void *addr);
/**
* Increment the program's data space by increment bytes.
*
* @param increment - the amount in bytes to increment the heap
* @return the previos program break on success, or NULL on failure
- *
*/
extern void *sbrk(intptr_t increment);