Use musl instead of litc in biscuit programs

master
Jiajie Chen 6 years ago
parent fb9a1d5f70
commit 9f46239322

@ -17,7 +17,7 @@ if (${ARCH} STREQUAL i386)
set(CMAKE_C_FLAGS "-m32 -mno-red-zone") set(CMAKE_C_FLAGS "-m32 -mno-red-zone")
elseif (${ARCH} STREQUAL x86_64) elseif (${ARCH} STREQUAL x86_64)
if(APPLE) if(APPLE)
set(PREFIX x86_64-elf-) set(PREFIX x86_64-linux-musl-)
endif () endif ()
set(CMAKE_C_FLAGS "-m64 -mno-red-zone") set(CMAKE_C_FLAGS "-m64 -mno-red-zone")
elseif (${ARCH} STREQUAL riscv32) elseif (${ARCH} STREQUAL riscv32)
@ -39,17 +39,13 @@ endif ()
set(CMAKE_ASM_COMPILER ${PREFIX}gcc) set(CMAKE_ASM_COMPILER ${PREFIX}gcc)
set(CMAKE_C_COMPILER ${PREFIX}gcc) set(CMAKE_C_COMPILER ${PREFIX}gcc)
set(CMAKE_RANLIB ${PREFIX}ranlib) set(CMAKE_RANLIB ${PREFIX}ranlib)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -MMD -MP -O -g -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-stack-protector -fPIC -std=gnu11") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-pointer-to-int-cast -Wno-format -MMD -MP -O -g -fPIC -std=gnu99")
set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS}) set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_C_LINK_FLAGS "${LINK_FLAGS} -nostdlib") # override default value to get rid of '-Wl,-search_paths_first -Wl,-headerpad_max_install_names' set(CMAKE_C_LINK_FLAGS "${LINK_FLAGS}") # override default value to get rid of '-Wl,-search_paths_first -Wl,-headerpad_max_install_names'
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # override default value to get rid of '-rdynamic' on Linux set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # override default value to get rid of '-rdynamic' on Linux
# Library
add_library(ulib ${LIBS})
# Execuatble # Execuatble
foreach (PATH ${SRCS}) foreach (PATH ${SRCS})
get_filename_component(NAME ${PATH} NAME_WE) get_filename_component(NAME ${PATH} NAME_WE)
add_executable(${NAME} ${PATH}) add_executable(${NAME} ${PATH})
target_link_libraries(${NAME} ulib gcc)
endforeach () endforeach ()

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static int lstn(uint16_t lport) static int lstn(uint16_t lport)
{ {
@ -126,6 +126,6 @@ int main(int argc, char **argv)
if (close(fd) == -1) if (close(fd) == -1)
err(-1, "close"); err(-1, "close");
fprintf(stderr, "wrote %zu bytes. rebooting.\n", did); fprintf(stderr, "wrote %zu bytes. rebooting.\n", did);
reboot(); reboot(RB_AUTOBOOT);
return 0; return 0;
} }

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static long static long
_fetch(long n) _fetch(long n)

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static long static long
nowms(void) nowms(void)

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[512]; static char buf[512];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[512]; static char buf[512];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <stdio.h> #include <common.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,9 +1,11 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
while (1) { while (1) {
char *ret = readline("input:"); printf("input:");
char buf[1024];
char *ret = gets(buf);
if (!ret) if (!ret)
break; break;
printf("got: %s\n", ret); printf("got: %s\n", ret);

@ -41,7 +41,7 @@
* *
*/ */
#include <stdio.h> #include <common.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/mman.h> #include <sys/mman.h>

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include<stdio.h> #include<common.h>
#include<unistd.h> #include<unistd.h>
#include<err.h> #include<err.h>
#include<poll.h> #include<poll.h>

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
void child(int id) void child(int id)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[5120]; static char buf[5120];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char buf[1024]; static char buf[1024];

@ -1,4 +1,4 @@
#include<stdio.h> #include<common.h>
#include<unistd.h> #include<unistd.h>
#include<err.h> #include<err.h>
#include<sys/socket.h> #include<sys/socket.h>

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main() int main()
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
void cmb(void) void cmb(void)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static void gcrun(char * const *cmd, long *_ngcs, long *_xput, double *_gcfrac) static void gcrun(char * const *cmd, long *_ngcs, long *_xput, double *_gcfrac)
{ {
@ -281,7 +281,7 @@ __attribute__((unused))
static void usage() static void usage()
{ {
fprintf(stderr, "usage: %s [-n target gcs] [-c target gc frac]" fprintf(stderr, "usage: %s [-n target gcs] [-c target gc frac]"
" -x <0gc xput> <allocr>\n", __progname); " -x <0gc xput> <allocr>\n", "halp");
exit(-1); exit(-1);
} }

@ -1,4 +1,4 @@
#include <stdio.h> #include <common.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -715,9 +715,7 @@ typedef struct {
struct dirent dents[]; struct dirent dents[];
} DIR; } DIR;
// tls is not fully supported at the time extern __thread int errno;
//extern __thread int errno;
extern int errno;
#define BUFSIZ 4096 #define BUFSIZ 4096
#define L_tmpnam 20 #define L_tmpnam 20

@ -0,0 +1,27 @@
#include <arpa/inet.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/kdev_t.h>
#include <pthread.h>
#include <poll.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <sys/un.h>
#include <sys/reboot.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <spawn.h>
#include <unistd.h>
#include <uchar.h>
#define WAIT_ANY (-1)
#include <limits.h>
#define uchar unsigned char

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static void fexec(char * const args[]) static void fexec(char * const args[])
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -64,9 +64,7 @@
#define SYS_FUTEX 31342 #define SYS_FUTEX 31342
#define SYS_GETTID 31343 #define SYS_GETTID 31343
// tls is not fully support at the time __thread int errno;
//__thread int errno;
int errno;
static int dolock = 1; static int dolock = 1;

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static char lmss[1ul << 11]; static char lmss[1ul << 11];
@ -81,7 +81,7 @@ int nc(int s)
static void usage() static void usage()
{ {
fprintf(stderr, "usage:\n" fprintf(stderr, "usage:\n"
"%s [-M] [-c host] [-p port] [-l listen port]\n", __progname); "%s [-M] [-c host] [-p port] [-l listen port]\n", "lnc");
exit(-1); exit(-1);
} }

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
void dprint(int fd, char *par, int left, int rec) void dprint(int fd, char *par, int left, int rec)
{ {
@ -77,7 +77,7 @@ void usage(void)
{ {
fprintf(stderr, "%s [-R]\n" fprintf(stderr, "%s [-R]\n"
"-R recurse subdirectories\n" "-R recurse subdirectories\n"
"\n", __progname); "\n", "ls");
exit(-1); exit(-1);
} }

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
void mkargs(char *line, char *args[], size_t n) void mkargs(char *line, char *args[], size_t n)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static long static long
nowms(void) nowms(void)

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
char *ps[1000]; char *ps[1000];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
__thread int id; __thread int id;

@ -1,4 +1,4 @@
#include <stdio.h> #include <common.h>
#include <unistd.h> #include <unistd.h>
int main(int argc, char **argv) int main(int argc, char **argv)

@ -1,4 +1,4 @@
#include <stdio.h> #include <common.h>
#include <unistd.h> #include <unistd.h>
int main(int argc, char **argv) int main(int argc, char **argv)
@ -6,6 +6,6 @@ int main(int argc, char **argv)
printf("syncing..."); printf("syncing...");
sync(); sync();
printf("done. rebooting...\n"); printf("done. rebooting...\n");
reboot(); reboot(RB_AUTOBOOT);
return 0; return 0;
} }

@ -1,4 +1,4 @@
#include <stdio.h> #include <common.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <err.h> #include <err.h>
@ -35,8 +35,7 @@ void rm(char *fn)
struct stat st; struct stat st;
if (stat(fn, &st) == -1) if (stat(fn, &st) == -1)
err(-1, "stat"); err(-1, "stat");
if (S_ISREG(st.st_mode) || S_ISSOCK(st.st_mode) || if (S_ISREG(st.st_mode) || S_ISSOCK(st.st_mode)) {
S_ISDEV(st.st_mode)) {
if (unlink(fn) == -1) if (unlink(fn) == -1)
err(-1, "unlink"); err(-1, "unlink");
return; return;
@ -51,7 +50,7 @@ int main(int argc, char **argv)
{ {
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "usage: %s <non-empty dir to remove>\n", fprintf(stderr, "usage: %s <non-empty dir to remove>\n",
__progname); "rmtree");
exit(-1); exit(-1);
} }
char *fn = argv[1]; char *fn = argv[1];

@ -1,4 +1,4 @@
#include <litc.h> #include <common.h>
static int lstn(uint16_t lport) static int lstn(uint16_t lport)
{ {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save