--- /dev/null
+
+int printf(const char* fmt, ...);
+
+int main()
+{
+ printf("hello world\n");
+ return 0;
+}
+
-void scf__release_pt (void* objdata);
-
-void* scf__auto_malloc(uintptr_t size);
-void scf__auto_ref(void* data);
-
-void scf__auto_freep (void** pp, scf__release_pt* release);
-void scf__auto_freep_array(void** pp, int nb_pointers, scf__release_pt* release);
-void scf__auto_free_array (void** pp, int size, int nb_pointers, scf__release_pt* release);
-
-int memcpy(void* dst, const void* src, uintptr_t n);
-
-int scf_printf(const char* fmt, ...);
+include "../lib/scf_capi.c";
const int MAT_TYPE_NONE = 0;
const int MAT_TYPE_U8 = 1;
int i;
for (i = 0; i < 4; i++)
- scf_printf("m3: %lf\n", dd[i]);
+ printf("m3: %lf\n", dd[i]);
// scf_printf("m1: %lf\n", *(double*)(m1->data + i * sizeof(double)));
return 0;
-int printf(char* fmt, int a);
+int printf(const char* fmt, ...);
int sort(int* a, int m, int n)
{
t = a[i];
while (i < j) {
- while (i < j && t < a[j])
+ while (i < j && t <= a[j])
j--;
a[i] = a[j];
a[j] = t;
- while (i < j && a[i] < t)
+ while (i < j && a[i] <= t)
i++;
a[j] = a[i];
a[i] = t;
int main()
{
- int a[10] = {1, 3, 5, 7, 9, 8, 6, 4, 2, 0};
+ int a[20] = {1, 3, 5, 7, 9, 8, 4, 2, 6, 0,
+ 11, 13, 15, 17, 19, 18, 16, 14, 12, 10};
- sort(a, 0, 9);
+ sort(a, 0, 19);
int i;
- for (i = 0; i < 10; i++)
+ for (i = 0; i < 20; i++)
printf("%d\n", a[i]);
return 0;
all:
as _start.s -o _start.o
as scf_syscall.s -o scf_syscall.o
- as scf_memcpy.s -o scf_memcpy.o
- as scf_memcmp.s -o scf_memcmp.o
- as scf_memset.s -o scf_memset.o
clean:
rm *.o
struct timespec st_ctim; /* Time of last status change */
};
-int scf__read(int fd, uint8_t* buf, uint64_t size)
-{
- return scf_syscall(SCF_read, fd, buf, size);
-}
-
-int scf__write(int fd, uint8_t* buf, uint64_t size)
-{
- return scf_syscall(SCF_write, fd, buf, size);
-}
-
-int scf__open(const char *pathname, int flags, ...);
-
-int scf__close(int fd)
-{
- return scf_syscall(SCF_close, fd);
-}
-
-int scf__fstat(int fd, stat *statbuf)
-{
- return scf_syscall(SCF_fstat, fd, statbuf);
-}
-
-intptr_t scf__mmap(void* addr, uint64_t len, int prot, int flags, int fd, uint64_t offset)
-{
- if (offset & 0xfff)
- return -EINVAL;
-
- return scf_syscall(SCF_mmap, addr, len, prot, flags, fd, offset);
-}
-
-int scf__munmap(void* addr, uint64_t len)
-{
- return scf_syscall(SCF_munmap, addr, len);
-}
-
.text
-.global scf_syscall, scf__open
+.global scf_syscall
scf_syscall:
syscall
ret
-
-scf__open:
- movq %rdx, %rcx
- movq %rsi, %rdx
- movq %rdi, %rsi
- movq $2, %rdi
- call scf_syscall
- ret
-.fill 0, 1, 0
+.fill 6, 1, 0
static char* __objs[] = {
"../lib/_start.o",
- "../lib/scf_syscall.o",
- "../lib/scf_linux_api.o",
"../lib/scf_object.o",
"../lib/scf_atomic.o",
};
}
if (optind >= argc) {
- fprintf(stderr, "Expected argument after options\n");
+ fprintf(stderr, "Usage: %s src0 [src1] [-o out]\n", argv[0]);
+ fprintf(stderr, "Usage: %s -c src0 [-o out]\n", argv[0]);
return -1;
}
return -1;
}
-
printf("%s(),%d, main ok\n", __func__, __LINE__);
return 0;
}