├── .GITIGNORE ├── Defaults.mk ├── LIBC.md ├── LICENSE ├── Makefile ├── README.md ├── Rules.mk ├── build.py ├── extras ├── VisualOS.tga └── zap-ext-light18.psf ├── install_tools.sh ├── main.py ├── rootfs.xml └── src ├── kernel ├── Makefile ├── bootloader.c ├── bootloader.h ├── elf.h ├── framebuffer.h ├── kernel.asm ├── kernel.c ├── kernel.h ├── kernel.inc ├── log.c ├── log.h ├── memory │ ├── bitmap.c │ ├── bitmap.h │ ├── memory.h │ ├── pageframe.c │ ├── pageframe.h │ ├── paging.asm │ ├── paging.c │ └── paging.h ├── module.h ├── scheduler │ ├── loader.c │ ├── loader.h │ ├── process.c │ ├── process.h │ ├── process.inc │ ├── scheduler.asm │ ├── scheduler.c │ ├── scheduler.h │ ├── scheduler.inc │ ├── timer.asm │ ├── timer.c │ └── timer.h ├── setup.c ├── shell │ ├── color.c │ ├── color.h │ ├── shell.c │ ├── shell.h │ ├── text.c │ └── text.h ├── stivale2.c ├── stivale2.h ├── symbols │ ├── symbol.c │ ├── symbol.h │ ├── unwind.c │ └── unwind.h ├── sys │ ├── sys.c │ ├── sys.h │ ├── sys_exec.c │ ├── sys_exit.c │ ├── sys_ioctl.c │ ├── sys_memory.c │ ├── sys_read.c │ ├── sys_system.c │ ├── sys_time.c │ └── sys_write.c └── x86_64 │ ├── acpi.c │ ├── acpi.h │ ├── apic │ ├── ioapic.c │ ├── ioapic.h │ ├── local_apic.c │ ├── local_apic.h │ ├── madt.c │ ├── madt.h │ └── trampoline.asm │ ├── atomic.asm │ ├── atomic.h │ ├── cpu.asm │ ├── cpu.c │ ├── cpu.h │ ├── cpu.inc │ ├── cpuid.asm │ ├── cpuid.h │ ├── gdt.asm │ ├── gdt.c │ ├── gdt.h │ ├── gdt.inc │ ├── idt.asm │ ├── idt.c │ ├── idt.h │ ├── interrupt_handler.c │ ├── interrupt_handler.h │ ├── io.asm │ ├── io.c │ ├── io.h │ ├── isr.asm │ ├── isr.c │ ├── isr.h │ ├── pci.c │ ├── pci.h │ ├── pci_id.c │ ├── pit.asm │ ├── pit.c │ ├── pit.h │ ├── syscall.asm │ ├── syscall.h │ └── userspace_test.asm ├── libraries ├── Makefile ├── _vos_syscall.h ├── _vos_syscall_k.c ├── _vos_syscall_u.c ├── dlmalloc │ ├── LICENSE │ ├── Makefile │ ├── _vos_interface_malloc.c │ ├── malloc.c │ └── malloc.h ├── musl │ ├── COPYRIGHT │ ├── Makefile │ ├── README │ ├── arch │ │ ├── generic │ │ │ ├── bits │ │ │ │ ├── dirent.h │ │ │ │ ├── errno.h │ │ │ │ ├── fcntl.h │ │ │ │ ├── fenv.h │ │ │ │ ├── hwcap.h │ │ │ │ ├── io.h │ │ │ │ ├── ioctl.h │ │ │ │ ├── ioctl_fix.h │ │ │ │ ├── ipc.h │ │ │ │ ├── ipcstat.h │ │ │ │ ├── kd.h │ │ │ │ ├── limits.h │ │ │ │ ├── link.h │ │ │ │ ├── mman.h │ │ │ │ ├── msg.h │ │ │ │ ├── poll.h │ │ │ │ ├── ptrace.h │ │ │ │ ├── resource.h │ │ │ │ ├── sem.h │ │ │ │ ├── shm.h │ │ │ │ ├── socket.h │ │ │ │ ├── soundcard.h │ │ │ │ ├── statfs.h │ │ │ │ ├── termios.h │ │ │ │ └── vt.h │ │ │ └── fp_arch.h │ │ └── x86_64 │ │ │ ├── atomic_arch.h │ │ │ ├── bits │ │ │ ├── alltypes.h.in │ │ │ ├── fenv.h │ │ │ ├── float.h │ │ │ ├── io.h │ │ │ ├── limits.h │ │ │ ├── mman.h │ │ │ ├── posix.h │ │ │ ├── ptrace.h │ │ │ ├── reg.h │ │ │ ├── sem.h │ │ │ ├── setjmp.h │ │ │ ├── signal.h │ │ │ ├── stat.h │ │ │ ├── stdint.h │ │ │ ├── syscall.h.in │ │ │ └── user.h │ │ │ ├── crt_arch.h │ │ │ ├── ksigaction.h │ │ │ ├── kstat.h │ │ │ ├── pthread_arch.h │ │ │ └── reloc.h │ ├── include │ │ ├── aio.h │ │ ├── alloca.h │ │ ├── alltypes.h.in │ │ ├── ar.h │ │ ├── arpa │ │ │ ├── ftp.h │ │ │ ├── inet.h │ │ │ ├── nameser.h │ │ │ ├── nameser_compat.h │ │ │ ├── telnet.h │ │ │ └── tftp.h │ │ ├── assert.h │ │ ├── byteswap.h │ │ ├── complex.h │ │ ├── cpio.h │ │ ├── crypt.h │ │ ├── ctype.h │ │ ├── dirent.h │ │ ├── dlfcn.h │ │ ├── elf.h │ │ ├── endian.h │ │ ├── err.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── features.h │ │ ├── fenv.h │ │ ├── float.h │ │ ├── fmtmsg.h │ │ ├── fnmatch.h │ │ ├── ftw.h │ │ ├── getopt.h │ │ ├── glob.h │ │ ├── grp.h │ │ ├── iconv.h │ │ ├── ifaddrs.h │ │ ├── inttypes.h │ │ ├── iso646.h │ │ ├── langinfo.h │ │ ├── lastlog.h │ │ ├── libgen.h │ │ ├── libintl.h │ │ ├── limits.h │ │ ├── link.h │ │ ├── locale.h │ │ ├── malloc.h │ │ ├── math.h │ │ ├── memory.h │ │ ├── mntent.h │ │ ├── monetary.h │ │ ├── mqueue.h │ │ ├── net │ │ │ ├── ethernet.h │ │ │ ├── if.h │ │ │ ├── if_arp.h │ │ │ └── route.h │ │ ├── netdb.h │ │ ├── netinet │ │ │ ├── ether.h │ │ │ ├── icmp6.h │ │ │ ├── if_ether.h │ │ │ ├── igmp.h │ │ │ ├── in.h │ │ │ ├── in_systm.h │ │ │ ├── ip.h │ │ │ ├── ip6.h │ │ │ ├── ip_icmp.h │ │ │ ├── tcp.h │ │ │ └── udp.h │ │ ├── netpacket │ │ │ └── packet.h │ │ ├── nl_types.h │ │ ├── paths.h │ │ ├── poll.h │ │ ├── pthread.h │ │ ├── pty.h │ │ ├── pwd.h │ │ ├── regex.h │ │ ├── resolv.h │ │ ├── sched.h │ │ ├── scsi │ │ │ ├── scsi.h │ │ │ ├── scsi_ioctl.h │ │ │ └── sg.h │ │ ├── search.h │ │ ├── semaphore.h │ │ ├── setjmp.h │ │ ├── shadow.h │ │ ├── signal.h │ │ ├── spawn.h │ │ ├── stdalign.h │ │ ├── stdarg.h │ │ ├── stdbool.h │ │ ├── stdc-predef.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── stdio.h │ │ ├── stdio_ext.h │ │ ├── stdlib.h │ │ ├── stdnoreturn.h │ │ ├── string.h │ │ ├── strings.h │ │ ├── stropts.h │ │ ├── sys │ │ │ ├── acct.h │ │ │ ├── auxv.h │ │ │ ├── cachectl.h │ │ │ ├── dir.h │ │ │ ├── epoll.h │ │ │ ├── errno.h │ │ │ ├── eventfd.h │ │ │ ├── fanotify.h │ │ │ ├── fcntl.h │ │ │ ├── file.h │ │ │ ├── fsuid.h │ │ │ ├── inotify.h │ │ │ ├── io.h │ │ │ ├── ioctl.h │ │ │ ├── ipc.h │ │ │ ├── kd.h │ │ │ ├── klog.h │ │ │ ├── membarrier.h │ │ │ ├── mman.h │ │ │ ├── mount.h │ │ │ ├── msg.h │ │ │ ├── mtio.h │ │ │ ├── param.h │ │ │ ├── personality.h │ │ │ ├── poll.h │ │ │ ├── prctl.h │ │ │ ├── procfs.h │ │ │ ├── ptrace.h │ │ │ ├── quota.h │ │ │ ├── random.h │ │ │ ├── reboot.h │ │ │ ├── reg.h │ │ │ ├── resource.h │ │ │ ├── select.h │ │ │ ├── sem.h │ │ │ ├── sendfile.h │ │ │ ├── shm.h │ │ │ ├── signal.h │ │ │ ├── signalfd.h │ │ │ ├── socket.h │ │ │ ├── soundcard.h │ │ │ ├── stat.h │ │ │ ├── statfs.h │ │ │ ├── statvfs.h │ │ │ ├── stropts.h │ │ │ ├── swap.h │ │ │ ├── syscall.h │ │ │ ├── sysinfo.h │ │ │ ├── syslog.h │ │ │ ├── sysmacros.h │ │ │ ├── termios.h │ │ │ ├── time.h │ │ │ ├── timeb.h │ │ │ ├── timerfd.h │ │ │ ├── times.h │ │ │ ├── timex.h │ │ │ ├── ttydefaults.h │ │ │ ├── types.h │ │ │ ├── ucontext.h │ │ │ ├── uio.h │ │ │ ├── un.h │ │ │ ├── user.h │ │ │ ├── utsname.h │ │ │ ├── vfs.h │ │ │ ├── vt.h │ │ │ ├── wait.h │ │ │ └── xattr.h │ │ ├── syscall.h │ │ ├── sysexits.h │ │ ├── syslog.h │ │ ├── tar.h │ │ ├── termios.h │ │ ├── tgmath.h │ │ ├── threads.h │ │ ├── time.h │ │ ├── uchar.h │ │ ├── ucontext.h │ │ ├── ulimit.h │ │ ├── unistd.h │ │ ├── utime.h │ │ ├── utmp.h │ │ ├── utmpx.h │ │ ├── values.h │ │ ├── wait.h │ │ ├── wchar.h │ │ ├── wctype.h │ │ └── wordexp.h │ ├── obj │ │ ├── include │ │ │ └── bits │ │ │ │ ├── alltypes.h │ │ │ │ └── syscall.h │ │ └── src │ │ │ └── internal │ │ │ └── version.h │ ├── src │ │ ├── conf │ │ │ ├── confstr.c │ │ │ ├── fpathconf.c │ │ │ ├── legacy.c │ │ │ ├── pathconf.c │ │ │ └── sysconf.c │ │ ├── env │ │ │ ├── __environ.c │ │ │ ├── __init_tls.c │ │ │ ├── __libc_start_main.c │ │ │ ├── __reset_tls.c │ │ │ ├── __stack_chk_fail.c │ │ │ ├── clearenv.c │ │ │ ├── getenv.c │ │ │ ├── putenv.c │ │ │ ├── secure_getenv.c │ │ │ ├── setenv.c │ │ │ └── unsetenv.c │ │ ├── errno │ │ │ ├── __errno_location.c │ │ │ ├── __strerror.h │ │ │ └── strerror.c │ │ ├── exit │ │ │ ├── _Exit.c │ │ │ ├── abort.c │ │ │ ├── abort_lock.c │ │ │ ├── assert.c │ │ │ ├── at_quick_exit.c │ │ │ ├── atexit.c │ │ │ ├── exit.c │ │ │ └── quick_exit.c │ │ ├── include │ │ │ ├── arpa │ │ │ │ └── inet.h │ │ │ ├── crypt.h │ │ │ ├── errno.h │ │ │ ├── features.h │ │ │ ├── langinfo.h │ │ │ ├── pthread.h │ │ │ ├── resolv.h │ │ │ ├── signal.h │ │ │ ├── stdio.h │ │ │ ├── stdlib.h │ │ │ ├── string.h │ │ │ ├── sys │ │ │ │ ├── auxv.h │ │ │ │ ├── membarrier.h │ │ │ │ ├── mman.h │ │ │ │ ├── sysinfo.h │ │ │ │ └── time.h │ │ │ ├── time.h │ │ │ ├── unistd.h │ │ │ └── wchar.h │ │ ├── internal │ │ │ ├── aio_impl.h │ │ │ ├── atomic.h │ │ │ ├── complex_impl.h │ │ │ ├── defsysinfo.c │ │ │ ├── dynlink.h │ │ │ ├── fdpic_crt.h │ │ │ ├── floatscan.c │ │ │ ├── floatscan.h │ │ │ ├── fork_impl.h │ │ │ ├── futex.h │ │ │ ├── intscan.c │ │ │ ├── intscan.h │ │ │ ├── ksigaction.h │ │ │ ├── libc.c │ │ │ ├── libc.h │ │ │ ├── libm.h │ │ │ ├── locale_impl.h │ │ │ ├── lock.h │ │ │ ├── procfdname.c │ │ │ ├── pthread_impl.h │ │ │ ├── shgetc.c │ │ │ ├── shgetc.h │ │ │ ├── stdio_impl.h │ │ │ ├── syscall.h │ │ │ ├── syscall_ret.c │ │ │ ├── vdso.c │ │ │ └── version.c │ │ ├── locale │ │ │ ├── __lctrans.c │ │ │ ├── __mo_lookup.c │ │ │ ├── big5.h │ │ │ ├── bind_textdomain_codeset.c │ │ │ ├── c_locale.c │ │ │ ├── catclose.c │ │ │ ├── catgets.c │ │ │ ├── catopen.c │ │ │ ├── codepages.h │ │ │ ├── dcngettext.c │ │ │ ├── duplocale.c │ │ │ ├── freelocale.c │ │ │ ├── gb18030.h │ │ │ ├── hkscs.h │ │ │ ├── iconv.c │ │ │ ├── iconv_close.c │ │ │ ├── jis0208.h │ │ │ ├── ksc.h │ │ │ ├── langinfo.c │ │ │ ├── legacychars.h │ │ │ ├── locale_map.c │ │ │ ├── localeconv.c │ │ │ ├── newlocale.c │ │ │ ├── pleval.c │ │ │ ├── pleval.h │ │ │ ├── revjis.h │ │ │ ├── setlocale.c │ │ │ ├── strcoll.c │ │ │ ├── strfmon.c │ │ │ ├── strxfrm.c │ │ │ ├── textdomain.c │ │ │ ├── uselocale.c │ │ │ ├── wcscoll.c │ │ │ └── wcsxfrm.c │ │ ├── math │ │ │ ├── __cos.c │ │ │ ├── __cosdf.c │ │ │ ├── __cosl.c │ │ │ ├── __expo2.c │ │ │ ├── __expo2f.c │ │ │ ├── __fpclassify.c │ │ │ ├── __fpclassifyf.c │ │ │ ├── __fpclassifyl.c │ │ │ ├── __invtrigl.c │ │ │ ├── __invtrigl.h │ │ │ ├── __math_divzero.c │ │ │ ├── __math_divzerof.c │ │ │ ├── __math_invalid.c │ │ │ ├── __math_invalidf.c │ │ │ ├── __math_invalidl.c │ │ │ ├── __math_oflow.c │ │ │ ├── __math_oflowf.c │ │ │ ├── __math_uflow.c │ │ │ ├── __math_uflowf.c │ │ │ ├── __math_xflow.c │ │ │ ├── __math_xflowf.c │ │ │ ├── __polevll.c │ │ │ ├── __rem_pio2.c │ │ │ ├── __rem_pio2_large.c │ │ │ ├── __rem_pio2f.c │ │ │ ├── __rem_pio2l.c │ │ │ ├── __signbit.c │ │ │ ├── __signbitf.c │ │ │ ├── __signbitl.c │ │ │ ├── __sin.c │ │ │ ├── __sindf.c │ │ │ ├── __sinl.c │ │ │ ├── __tan.c │ │ │ ├── __tandf.c │ │ │ ├── __tanl.c │ │ │ ├── acos.c │ │ │ ├── acosf.c │ │ │ ├── acosh.c │ │ │ ├── acoshf.c │ │ │ ├── acoshl.c │ │ │ ├── acosl.c │ │ │ ├── asin.c │ │ │ ├── asinf.c │ │ │ ├── asinh.c │ │ │ ├── asinhf.c │ │ │ ├── asinhl.c │ │ │ ├── asinl.c │ │ │ ├── atan.c │ │ │ ├── atan2.c │ │ │ ├── atan2f.c │ │ │ ├── atan2l.c │ │ │ ├── atanf.c │ │ │ ├── atanh.c │ │ │ ├── atanhf.c │ │ │ ├── atanhl.c │ │ │ ├── atanl.c │ │ │ ├── cbrt.c │ │ │ ├── cbrtf.c │ │ │ ├── cbrtl.c │ │ │ ├── ceil.c │ │ │ ├── ceilf.c │ │ │ ├── ceill.c │ │ │ ├── copysign.c │ │ │ ├── copysignf.c │ │ │ ├── copysignl.c │ │ │ ├── cos.c │ │ │ ├── cosf.c │ │ │ ├── cosh.c │ │ │ ├── coshf.c │ │ │ ├── coshl.c │ │ │ ├── cosl.c │ │ │ ├── erf.c │ │ │ ├── erff.c │ │ │ ├── erfl.c │ │ │ ├── exp.c │ │ │ ├── exp10.c │ │ │ ├── exp10f.c │ │ │ ├── exp10l.c │ │ │ ├── exp2.c │ │ │ ├── exp2f.c │ │ │ ├── exp2f_data.c │ │ │ ├── exp2f_data.h │ │ │ ├── exp2l.c │ │ │ ├── exp_data.c │ │ │ ├── exp_data.h │ │ │ ├── expf.c │ │ │ ├── expl.c │ │ │ ├── expm1.c │ │ │ ├── expm1f.c │ │ │ ├── expm1l.c │ │ │ ├── fabs.c │ │ │ ├── fabsf.c │ │ │ ├── fabsl.c │ │ │ ├── fdim.c │ │ │ ├── fdimf.c │ │ │ ├── fdiml.c │ │ │ ├── finite.c │ │ │ ├── finitef.c │ │ │ ├── floor.c │ │ │ ├── floorf.c │ │ │ ├── floorl.c │ │ │ ├── fma.c │ │ │ ├── fmaf.c │ │ │ ├── fmal.c │ │ │ ├── fmax.c │ │ │ ├── fmaxf.c │ │ │ ├── fmaxl.c │ │ │ ├── fmin.c │ │ │ ├── fminf.c │ │ │ ├── fminl.c │ │ │ ├── fmod.c │ │ │ ├── fmodf.c │ │ │ ├── fmodl.c │ │ │ ├── frexp.c │ │ │ ├── frexpf.c │ │ │ ├── frexpl.c │ │ │ ├── hypot.c │ │ │ ├── hypotf.c │ │ │ ├── hypotl.c │ │ │ ├── ilogb.c │ │ │ ├── ilogbf.c │ │ │ ├── ilogbl.c │ │ │ ├── j0.c │ │ │ ├── j0f.c │ │ │ ├── j1.c │ │ │ ├── j1f.c │ │ │ ├── jn.c │ │ │ ├── jnf.c │ │ │ ├── ldexp.c │ │ │ ├── ldexpf.c │ │ │ ├── ldexpl.c │ │ │ ├── lgamma.c │ │ │ ├── lgamma_r.c │ │ │ ├── lgammaf.c │ │ │ ├── lgammaf_r.c │ │ │ ├── lgammal.c │ │ │ ├── llrint.c │ │ │ ├── llrintf.c │ │ │ ├── llrintl.c │ │ │ ├── llround.c │ │ │ ├── llroundf.c │ │ │ ├── llroundl.c │ │ │ ├── log.c │ │ │ ├── log10.c │ │ │ ├── log10f.c │ │ │ ├── log10l.c │ │ │ ├── log1p.c │ │ │ ├── log1pf.c │ │ │ ├── log1pl.c │ │ │ ├── log2.c │ │ │ ├── log2_data.c │ │ │ ├── log2_data.h │ │ │ ├── log2f.c │ │ │ ├── log2f_data.c │ │ │ ├── log2f_data.h │ │ │ ├── log2l.c │ │ │ ├── log_data.c │ │ │ ├── log_data.h │ │ │ ├── logb.c │ │ │ ├── logbf.c │ │ │ ├── logbl.c │ │ │ ├── logf.c │ │ │ ├── logf_data.c │ │ │ ├── logf_data.h │ │ │ ├── logl.c │ │ │ ├── lrint.c │ │ │ ├── lrintf.c │ │ │ ├── lrintl.c │ │ │ ├── lround.c │ │ │ ├── lroundf.c │ │ │ ├── lroundl.c │ │ │ ├── modf.c │ │ │ ├── modff.c │ │ │ ├── modfl.c │ │ │ ├── nan.c │ │ │ ├── nanf.c │ │ │ ├── nanl.c │ │ │ ├── nearbyint.c │ │ │ ├── nearbyintf.c │ │ │ ├── nearbyintl.c │ │ │ ├── nextafter.c │ │ │ ├── nextafterf.c │ │ │ ├── nextafterl.c │ │ │ ├── nexttoward.c │ │ │ ├── nexttowardf.c │ │ │ ├── nexttowardl.c │ │ │ ├── pow.c │ │ │ ├── pow_data.c │ │ │ ├── pow_data.h │ │ │ ├── powf.c │ │ │ ├── powf_data.c │ │ │ ├── powf_data.h │ │ │ ├── powl.c │ │ │ ├── remainder.c │ │ │ ├── remainderf.c │ │ │ ├── remainderl.c │ │ │ ├── remquo.c │ │ │ ├── remquof.c │ │ │ ├── remquol.c │ │ │ ├── rint.c │ │ │ ├── rintf.c │ │ │ ├── rintl.c │ │ │ ├── round.c │ │ │ ├── roundf.c │ │ │ ├── roundl.c │ │ │ ├── scalb.c │ │ │ ├── scalbf.c │ │ │ ├── scalbln.c │ │ │ ├── scalblnf.c │ │ │ ├── scalblnl.c │ │ │ ├── scalbn.c │ │ │ ├── scalbnf.c │ │ │ ├── scalbnl.c │ │ │ ├── signgam.c │ │ │ ├── significand.c │ │ │ ├── significandf.c │ │ │ ├── sin.c │ │ │ ├── sincos.c │ │ │ ├── sincosf.c │ │ │ ├── sincosl.c │ │ │ ├── sinf.c │ │ │ ├── sinh.c │ │ │ ├── sinhf.c │ │ │ ├── sinhl.c │ │ │ ├── sinl.c │ │ │ ├── sqrt.c │ │ │ ├── sqrt_data.c │ │ │ ├── sqrt_data.h │ │ │ ├── sqrtf.c │ │ │ ├── sqrtl.c │ │ │ ├── tan.c │ │ │ ├── tanf.c │ │ │ ├── tanh.c │ │ │ ├── tanhf.c │ │ │ ├── tanhl.c │ │ │ ├── tanl.c │ │ │ ├── tgamma.c │ │ │ ├── tgammaf.c │ │ │ ├── tgammal.c │ │ │ ├── trunc.c │ │ │ ├── truncf.c │ │ │ ├── truncl.c │ │ │ └── x86_64 │ │ │ │ ├── __invtrigl.s │ │ │ │ ├── acosl.s │ │ │ │ ├── asinl.s │ │ │ │ ├── atan2l.s │ │ │ │ ├── atanl.s │ │ │ │ ├── ceill.s │ │ │ │ ├── exp2l.s │ │ │ │ ├── expl.s │ │ │ │ ├── expm1l.s │ │ │ │ ├── fabs.c │ │ │ │ ├── fabsf.c │ │ │ │ ├── fabsl.c │ │ │ │ ├── floorl.s │ │ │ │ ├── fma.c │ │ │ │ ├── fmaf.c │ │ │ │ ├── fmodl.c │ │ │ │ ├── llrint.c │ │ │ │ ├── llrintf.c │ │ │ │ ├── llrintl.c │ │ │ │ ├── log10l.s │ │ │ │ ├── log1pl.s │ │ │ │ ├── log2l.s │ │ │ │ ├── logl.s │ │ │ │ ├── lrint.c │ │ │ │ ├── lrintf.c │ │ │ │ ├── lrintl.c │ │ │ │ ├── remainderl.c │ │ │ │ ├── remquol.c │ │ │ │ ├── rintl.c │ │ │ │ ├── sqrt.c │ │ │ │ ├── sqrtf.c │ │ │ │ ├── sqrtl.c │ │ │ │ └── truncl.s │ │ ├── misc │ │ │ ├── a64l.c │ │ │ ├── basename.c │ │ │ ├── dirname.c │ │ │ ├── ffs.c │ │ │ ├── ffsl.c │ │ │ ├── ffsll.c │ │ │ ├── fmtmsg.c │ │ │ ├── forkpty.c │ │ │ ├── get_current_dir_name.c │ │ │ ├── getauxval.c │ │ │ ├── getdomainname.c │ │ │ ├── getentropy.c │ │ │ ├── gethostid.c │ │ │ ├── getopt.c │ │ │ ├── getopt_long.c │ │ │ ├── getpriority.c │ │ │ ├── getresgid.c │ │ │ ├── getresuid.c │ │ │ ├── getrlimit.c │ │ │ ├── getrusage.c │ │ │ ├── getsubopt.c │ │ │ ├── initgroups.c │ │ │ ├── ioctl.c │ │ │ ├── issetugid.c │ │ │ ├── lockf.c │ │ │ ├── login_tty.c │ │ │ ├── mntent.c │ │ │ ├── nftw.c │ │ │ ├── openpty.c │ │ │ ├── ptsname.c │ │ │ ├── pty.c │ │ │ ├── realpath.c │ │ │ ├── setdomainname.c │ │ │ ├── setpriority.c │ │ │ ├── setrlimit.c │ │ │ ├── syscall.c │ │ │ ├── syslog.c │ │ │ ├── uname.c │ │ │ └── wordexp.c │ │ ├── multibyte │ │ │ ├── btowc.c │ │ │ ├── c16rtomb.c │ │ │ ├── c32rtomb.c │ │ │ ├── internal.c │ │ │ ├── internal.h │ │ │ ├── mblen.c │ │ │ ├── mbrlen.c │ │ │ ├── mbrtoc16.c │ │ │ ├── mbrtoc32.c │ │ │ ├── mbrtowc.c │ │ │ ├── mbsinit.c │ │ │ ├── mbsnrtowcs.c │ │ │ ├── mbsrtowcs.c │ │ │ ├── mbstowcs.c │ │ │ ├── mbtowc.c │ │ │ ├── wcrtomb.c │ │ │ ├── wcsnrtombs.c │ │ │ ├── wcsrtombs.c │ │ │ ├── wcstombs.c │ │ │ ├── wctob.c │ │ │ └── wctomb.c │ │ ├── setjmp │ │ │ ├── longjmp.c │ │ │ ├── setjmp.c │ │ │ └── x86_64 │ │ │ │ ├── longjmp.s │ │ │ │ └── setjmp.s │ │ ├── signal │ │ │ ├── block.c │ │ │ ├── getitimer.c │ │ │ ├── kill.c │ │ │ ├── killpg.c │ │ │ ├── psiginfo.c │ │ │ ├── psignal.c │ │ │ ├── raise.c │ │ │ ├── restore.c │ │ │ ├── setitimer.c │ │ │ ├── sigaction.c │ │ │ ├── sigaddset.c │ │ │ ├── sigaltstack.c │ │ │ ├── sigandset.c │ │ │ ├── sigdelset.c │ │ │ ├── sigemptyset.c │ │ │ ├── sigfillset.c │ │ │ ├── sighold.c │ │ │ ├── sigignore.c │ │ │ ├── siginterrupt.c │ │ │ ├── sigisemptyset.c │ │ │ ├── sigismember.c │ │ │ ├── siglongjmp.c │ │ │ ├── signal.c │ │ │ ├── sigorset.c │ │ │ ├── sigpause.c │ │ │ ├── sigpending.c │ │ │ ├── sigprocmask.c │ │ │ ├── sigqueue.c │ │ │ ├── sigrelse.c │ │ │ ├── sigrtmax.c │ │ │ ├── sigrtmin.c │ │ │ ├── sigset.c │ │ │ ├── sigsetjmp.c │ │ │ ├── sigsetjmp_tail.c │ │ │ ├── sigsuspend.c │ │ │ ├── sigtimedwait.c │ │ │ ├── sigwait.c │ │ │ ├── sigwaitinfo.c │ │ │ └── x86_64 │ │ │ │ ├── restore.s │ │ │ │ └── sigsetjmp.s │ │ ├── stdio │ │ │ ├── __fclose_ca.c │ │ │ ├── __fdopen.c │ │ │ ├── __fmodeflags.c │ │ │ ├── __fopen_rb_ca.c │ │ │ ├── __lockfile.c │ │ │ ├── __overflow.c │ │ │ ├── __stdio_close.c │ │ │ ├── __stdio_exit.c │ │ │ ├── __stdio_read.c │ │ │ ├── __stdio_seek.c │ │ │ ├── __stdio_write.c │ │ │ ├── __stdout_write.c │ │ │ ├── __toread.c │ │ │ ├── __towrite.c │ │ │ ├── __uflow.c │ │ │ ├── asprintf.c │ │ │ ├── clearerr.c │ │ │ ├── dprintf.c │ │ │ ├── ext.c │ │ │ ├── ext2.c │ │ │ ├── fclose.c │ │ │ ├── feof.c │ │ │ ├── ferror.c │ │ │ ├── fflush.c │ │ │ ├── fgetc.c │ │ │ ├── fgetln.c │ │ │ ├── fgetpos.c │ │ │ ├── fgets.c │ │ │ ├── fgetwc.c │ │ │ ├── fgetws.c │ │ │ ├── fileno.c │ │ │ ├── flockfile.c │ │ │ ├── fmemopen.c │ │ │ ├── fopen.c │ │ │ ├── fopencookie.c │ │ │ ├── fprintf.c │ │ │ ├── fputc.c │ │ │ ├── fputs.c │ │ │ ├── fputwc.c │ │ │ ├── fputws.c │ │ │ ├── fread.c │ │ │ ├── freopen.c │ │ │ ├── fscanf.c │ │ │ ├── fseek.c │ │ │ ├── fsetpos.c │ │ │ ├── ftell.c │ │ │ ├── ftrylockfile.c │ │ │ ├── funlockfile.c │ │ │ ├── fwide.c │ │ │ ├── fwprintf.c │ │ │ ├── fwrite.c │ │ │ ├── fwscanf.c │ │ │ ├── getc.c │ │ │ ├── getc.h │ │ │ ├── getc_unlocked.c │ │ │ ├── getchar.c │ │ │ ├── getchar_unlocked.c │ │ │ ├── getdelim.c │ │ │ ├── getline.c │ │ │ ├── gets.c │ │ │ ├── getw.c │ │ │ ├── getwc.c │ │ │ ├── getwchar.c │ │ │ ├── ofl.c │ │ │ ├── ofl_add.c │ │ │ ├── open_memstream.c │ │ │ ├── open_wmemstream.c │ │ │ ├── pclose.c │ │ │ ├── perror.c │ │ │ ├── popen.c │ │ │ ├── printf.c │ │ │ ├── putc.c │ │ │ ├── putc.h │ │ │ ├── putc_unlocked.c │ │ │ ├── putchar.c │ │ │ ├── putchar_unlocked.c │ │ │ ├── puts.c │ │ │ ├── putw.c │ │ │ ├── putwc.c │ │ │ ├── putwchar.c │ │ │ ├── remove.c │ │ │ ├── rename.c │ │ │ ├── rewind.c │ │ │ ├── scanf.c │ │ │ ├── setbuf.c │ │ │ ├── setbuffer.c │ │ │ ├── setlinebuf.c │ │ │ ├── setvbuf.c │ │ │ ├── snprintf.c │ │ │ ├── sprintf.c │ │ │ ├── sscanf.c │ │ │ ├── stderr.c │ │ │ ├── stdin.c │ │ │ ├── stdout.c │ │ │ ├── swprintf.c │ │ │ ├── swscanf.c │ │ │ ├── tempnam.c │ │ │ ├── tmpfile.c │ │ │ ├── tmpnam.c │ │ │ ├── ungetc.c │ │ │ ├── ungetwc.c │ │ │ ├── vasprintf.c │ │ │ ├── vdprintf.c │ │ │ ├── vfprintf.c │ │ │ ├── vfscanf.c │ │ │ ├── vfwprintf.c │ │ │ ├── vfwscanf.c │ │ │ ├── vprintf.c │ │ │ ├── vscanf.c │ │ │ ├── vsnprintf.c │ │ │ ├── vsprintf.c │ │ │ ├── vsscanf.c │ │ │ ├── vswprintf.c │ │ │ ├── vswscanf.c │ │ │ ├── vwprintf.c │ │ │ ├── vwscanf.c │ │ │ ├── wprintf.c │ │ │ └── wscanf.c │ │ ├── string │ │ │ ├── bcmp.c │ │ │ ├── bcopy.c │ │ │ ├── bzero.c │ │ │ ├── explicit_bzero.c │ │ │ ├── index.c │ │ │ ├── memccpy.c │ │ │ ├── memchr.c │ │ │ ├── memcmp.c │ │ │ ├── memcpy.c │ │ │ ├── memmem.c │ │ │ ├── memmove.c │ │ │ ├── mempcpy.c │ │ │ ├── memrchr.c │ │ │ ├── memset.c │ │ │ ├── rindex.c │ │ │ ├── stpcpy.c │ │ │ ├── stpncpy.c │ │ │ ├── strcasecmp.c │ │ │ ├── strcasestr.c │ │ │ ├── strcat.c │ │ │ ├── strchr.c │ │ │ ├── strchrnul.c │ │ │ ├── strcmp.c │ │ │ ├── strcpy.c │ │ │ ├── strcspn.c │ │ │ ├── strdup.c │ │ │ ├── strerror_r.c │ │ │ ├── strlcat.c │ │ │ ├── strlcpy.c │ │ │ ├── strlen.c │ │ │ ├── strncasecmp.c │ │ │ ├── strncat.c │ │ │ ├── strncmp.c │ │ │ ├── strncpy.c │ │ │ ├── strndup.c │ │ │ ├── strnlen.c │ │ │ ├── strpbrk.c │ │ │ ├── strrchr.c │ │ │ ├── strsep.c │ │ │ ├── strsignal.c │ │ │ ├── strspn.c │ │ │ ├── strstr.c │ │ │ ├── strtok.c │ │ │ ├── strtok_r.c │ │ │ ├── strverscmp.c │ │ │ ├── swab.c │ │ │ ├── wcpcpy.c │ │ │ ├── wcpncpy.c │ │ │ ├── wcscasecmp.c │ │ │ ├── wcscasecmp_l.c │ │ │ ├── wcscat.c │ │ │ ├── wcschr.c │ │ │ ├── wcscmp.c │ │ │ ├── wcscpy.c │ │ │ ├── wcscspn.c │ │ │ ├── wcsdup.c │ │ │ ├── wcslen.c │ │ │ ├── wcsncasecmp.c │ │ │ ├── wcsncasecmp_l.c │ │ │ ├── wcsncat.c │ │ │ ├── wcsncmp.c │ │ │ ├── wcsncpy.c │ │ │ ├── wcsnlen.c │ │ │ ├── wcspbrk.c │ │ │ ├── wcsrchr.c │ │ │ ├── wcsspn.c │ │ │ ├── wcsstr.c │ │ │ ├── wcstok.c │ │ │ ├── wcswcs.c │ │ │ ├── wmemchr.c │ │ │ ├── wmemcmp.c │ │ │ ├── wmemcpy.c │ │ │ ├── wmemmove.c │ │ │ ├── wmemset.c │ │ │ └── x86_64 │ │ │ │ ├── memcpy.s │ │ │ │ ├── memmove.s │ │ │ │ └── memset.s │ │ ├── thread │ │ │ ├── __lock.c │ │ │ ├── __set_thread_area.c │ │ │ ├── __syscall_cp.c │ │ │ ├── __timedwait.c │ │ │ ├── __tls_get_addr.c │ │ │ ├── __unmapself.c │ │ │ ├── __wait.c │ │ │ ├── call_once.c │ │ │ ├── clone.c │ │ │ ├── cnd_broadcast.c │ │ │ ├── cnd_destroy.c │ │ │ ├── cnd_init.c │ │ │ ├── cnd_signal.c │ │ │ ├── cnd_timedwait.c │ │ │ ├── cnd_wait.c │ │ │ ├── default_attr.c │ │ │ ├── lock_ptc.c │ │ │ ├── mtx_destroy.c │ │ │ ├── mtx_init.c │ │ │ ├── mtx_lock.c │ │ │ ├── mtx_timedlock.c │ │ │ ├── mtx_trylock.c │ │ │ ├── mtx_unlock.c │ │ │ ├── pthread_atfork.c │ │ │ ├── pthread_attr_destroy.c │ │ │ ├── pthread_attr_get.c │ │ │ ├── pthread_attr_init.c │ │ │ ├── pthread_attr_setdetachstate.c │ │ │ ├── pthread_attr_setguardsize.c │ │ │ ├── pthread_attr_setinheritsched.c │ │ │ ├── pthread_attr_setschedparam.c │ │ │ ├── pthread_attr_setschedpolicy.c │ │ │ ├── pthread_attr_setscope.c │ │ │ ├── pthread_attr_setstack.c │ │ │ ├── pthread_attr_setstacksize.c │ │ │ ├── pthread_barrier_destroy.c │ │ │ ├── pthread_barrier_init.c │ │ │ ├── pthread_barrier_wait.c │ │ │ ├── pthread_barrierattr_destroy.c │ │ │ ├── pthread_barrierattr_init.c │ │ │ ├── pthread_barrierattr_setpshared.c │ │ │ ├── pthread_cancel.c │ │ │ ├── pthread_cleanup_push.c │ │ │ ├── pthread_cond_broadcast.c │ │ │ ├── pthread_cond_destroy.c │ │ │ ├── pthread_cond_init.c │ │ │ ├── pthread_cond_signal.c │ │ │ ├── pthread_cond_timedwait.c │ │ │ ├── pthread_cond_wait.c │ │ │ ├── pthread_condattr_destroy.c │ │ │ ├── pthread_condattr_init.c │ │ │ ├── pthread_condattr_setclock.c │ │ │ ├── pthread_condattr_setpshared.c │ │ │ ├── pthread_create.c │ │ │ ├── pthread_detach.c │ │ │ ├── pthread_equal.c │ │ │ ├── pthread_getattr_np.c │ │ │ ├── pthread_getconcurrency.c │ │ │ ├── pthread_getcpuclockid.c │ │ │ ├── pthread_getschedparam.c │ │ │ ├── pthread_getspecific.c │ │ │ ├── pthread_join.c │ │ │ ├── pthread_key_create.c │ │ │ ├── pthread_kill.c │ │ │ ├── pthread_mutex_consistent.c │ │ │ ├── pthread_mutex_destroy.c │ │ │ ├── pthread_mutex_getprioceiling.c │ │ │ ├── pthread_mutex_init.c │ │ │ ├── pthread_mutex_lock.c │ │ │ ├── pthread_mutex_setprioceiling.c │ │ │ ├── pthread_mutex_timedlock.c │ │ │ ├── pthread_mutex_trylock.c │ │ │ ├── pthread_mutex_unlock.c │ │ │ ├── pthread_mutexattr_destroy.c │ │ │ ├── pthread_mutexattr_init.c │ │ │ ├── pthread_mutexattr_setprotocol.c │ │ │ ├── pthread_mutexattr_setpshared.c │ │ │ ├── pthread_mutexattr_setrobust.c │ │ │ ├── pthread_mutexattr_settype.c │ │ │ ├── pthread_once.c │ │ │ ├── pthread_rwlock_destroy.c │ │ │ ├── pthread_rwlock_init.c │ │ │ ├── pthread_rwlock_rdlock.c │ │ │ ├── pthread_rwlock_timedrdlock.c │ │ │ ├── pthread_rwlock_timedwrlock.c │ │ │ ├── pthread_rwlock_tryrdlock.c │ │ │ ├── pthread_rwlock_trywrlock.c │ │ │ ├── pthread_rwlock_unlock.c │ │ │ ├── pthread_rwlock_wrlock.c │ │ │ ├── pthread_rwlockattr_destroy.c │ │ │ ├── pthread_rwlockattr_init.c │ │ │ ├── pthread_rwlockattr_setpshared.c │ │ │ ├── pthread_self.c │ │ │ ├── pthread_setattr_default_np.c │ │ │ ├── pthread_setcancelstate.c │ │ │ ├── pthread_setcanceltype.c │ │ │ ├── pthread_setconcurrency.c │ │ │ ├── pthread_setname_np.c │ │ │ ├── pthread_setschedparam.c │ │ │ ├── pthread_setschedprio.c │ │ │ ├── pthread_setspecific.c │ │ │ ├── pthread_sigmask.c │ │ │ ├── pthread_spin_destroy.c │ │ │ ├── pthread_spin_init.c │ │ │ ├── pthread_spin_lock.c │ │ │ ├── pthread_spin_trylock.c │ │ │ ├── pthread_spin_unlock.c │ │ │ ├── pthread_testcancel.c │ │ │ ├── sem_destroy.c │ │ │ ├── sem_getvalue.c │ │ │ ├── sem_init.c │ │ │ ├── sem_open.c │ │ │ ├── sem_post.c │ │ │ ├── sem_timedwait.c │ │ │ ├── sem_trywait.c │ │ │ ├── sem_unlink.c │ │ │ ├── sem_wait.c │ │ │ ├── synccall.c │ │ │ ├── syscall_cp.c │ │ │ ├── thrd_create.c │ │ │ ├── thrd_exit.c │ │ │ ├── thrd_join.c │ │ │ ├── thrd_sleep.c │ │ │ ├── thrd_yield.c │ │ │ ├── tls.c │ │ │ ├── tss_create.c │ │ │ ├── tss_delete.c │ │ │ ├── tss_set.c │ │ │ ├── vmlock.c │ │ │ └── x86_64 │ │ │ │ ├── __set_thread_area.s │ │ │ │ ├── __unmapself.s │ │ │ │ ├── clone.s │ │ │ │ └── syscall_cp.s │ │ ├── time │ │ │ ├── __map_file.c │ │ │ ├── __month_to_secs.c │ │ │ ├── __secs_to_tm.c │ │ │ ├── __tm_to_secs.c │ │ │ ├── __tz.c │ │ │ ├── __year_to_secs.c │ │ │ ├── asctime.c │ │ │ ├── asctime_r.c │ │ │ ├── clock.c │ │ │ ├── clock_getcpuclockid.c │ │ │ ├── clock_getres.c │ │ │ ├── clock_gettime.c │ │ │ ├── clock_nanosleep.c │ │ │ ├── clock_settime.c │ │ │ ├── ctime.c │ │ │ ├── ctime_r.c │ │ │ ├── difftime.c │ │ │ ├── ftime.c │ │ │ ├── getdate.c │ │ │ ├── gettimeofday.c │ │ │ ├── gmtime.c │ │ │ ├── gmtime_r.c │ │ │ ├── localtime.c │ │ │ ├── localtime_r.c │ │ │ ├── mktime.c │ │ │ ├── nanosleep.c │ │ │ ├── strftime.c │ │ │ ├── strptime.c │ │ │ ├── time.c │ │ │ ├── time_impl.h │ │ │ ├── timegm.c │ │ │ ├── timer_create.c │ │ │ ├── timer_delete.c │ │ │ ├── timer_getoverrun.c │ │ │ ├── timer_gettime.c │ │ │ ├── timer_settime.c │ │ │ ├── times.c │ │ │ ├── timespec_get.c │ │ │ ├── utime.c │ │ │ └── wcsftime.c │ │ └── unistd │ │ │ ├── _exit.c │ │ │ ├── access.c │ │ │ ├── acct.c │ │ │ ├── alarm.c │ │ │ ├── chdir.c │ │ │ ├── chown.c │ │ │ ├── close.c │ │ │ ├── ctermid.c │ │ │ ├── dup.c │ │ │ ├── dup2.c │ │ │ ├── dup3.c │ │ │ ├── faccessat.c │ │ │ ├── fchdir.c │ │ │ ├── fchown.c │ │ │ ├── fchownat.c │ │ │ ├── fdatasync.c │ │ │ ├── fsync.c │ │ │ ├── ftruncate.c │ │ │ ├── getcwd.c │ │ │ ├── getegid.c │ │ │ ├── geteuid.c │ │ │ ├── getgid.c │ │ │ ├── getgroups.c │ │ │ ├── gethostname.c │ │ │ ├── getlogin.c │ │ │ ├── getlogin_r.c │ │ │ ├── getpgid.c │ │ │ ├── getpgrp.c │ │ │ ├── getpid.c │ │ │ ├── getppid.c │ │ │ ├── getsid.c │ │ │ ├── getuid.c │ │ │ ├── isatty.c │ │ │ ├── lchown.c │ │ │ ├── link.c │ │ │ ├── linkat.c │ │ │ ├── lseek.c │ │ │ ├── nice.c │ │ │ ├── pause.c │ │ │ ├── pipe.c │ │ │ ├── pipe2.c │ │ │ ├── posix_close.c │ │ │ ├── pread.c │ │ │ ├── preadv.c │ │ │ ├── pwrite.c │ │ │ ├── pwritev.c │ │ │ ├── read.c │ │ │ ├── readlink.c │ │ │ ├── readlinkat.c │ │ │ ├── readv.c │ │ │ ├── renameat.c │ │ │ ├── rmdir.c │ │ │ ├── setegid.c │ │ │ ├── seteuid.c │ │ │ ├── setgid.c │ │ │ ├── setpgid.c │ │ │ ├── setpgrp.c │ │ │ ├── setregid.c │ │ │ ├── setresgid.c │ │ │ ├── setresuid.c │ │ │ ├── setreuid.c │ │ │ ├── setsid.c │ │ │ ├── setuid.c │ │ │ ├── setxid.c │ │ │ ├── sleep.c │ │ │ ├── symlink.c │ │ │ ├── symlinkat.c │ │ │ ├── sync.c │ │ │ ├── tcgetpgrp.c │ │ │ ├── tcsetpgrp.c │ │ │ ├── truncate.c │ │ │ ├── ttyname.c │ │ │ ├── ttyname_r.c │ │ │ ├── ualarm.c │ │ │ ├── unlink.c │ │ │ ├── unlinkat.c │ │ │ ├── usleep.c │ │ │ ├── write.c │ │ │ └── writev.c │ └── tools │ │ ├── add-cfi.common.awk │ │ └── add-cfi.x86_64.awk └── voslib │ └── sysinfo.c ├── limine.cfg ├── modules ├── Makefile ├── README.md └── applications │ └── hello_world │ └── hello_world.asm └── vos.ld /.GITIGNORE: -------------------------------------------------------------------------------- 1 | /build/ 2 | /bin/ 3 | /.vscode/ 4 | /__pycache__/ 5 | /.DS_Store -------------------------------------------------------------------------------- /extras/VisualOS.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/extras/VisualOS.tga -------------------------------------------------------------------------------- /extras/zap-ext-light18.psf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/extras/zap-ext-light18.psf -------------------------------------------------------------------------------- /install_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | apt-get install python3 -y 4 | apt-get install gcc -y 5 | apt-get install nasm -y 6 | apt-get install mtools -y 7 | 8 | # apt-get install python3-pip -y 9 | # pip3 install pycdlib -------------------------------------------------------------------------------- /src/kernel/scheduler/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: timer.c 3 | * ***************************************************************************** 4 | * Copyright 2021 Scott Maday 5 | * Check the LICENSE file that came with this program for licensing terms 6 | */ 7 | 8 | #include "x86_64/apic/local_apic.h" 9 | #include "timer.h" 10 | 11 | 12 | void timer_set_ticks(timer_ticks_t ticks) { 13 | local_apic_set_timer_count(ticks); 14 | } -------------------------------------------------------------------------------- /src/kernel/sys/sys_exec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: sys_exec.c 3 | * ***************************************************************************** 4 | * Copyright 2021 Scott Maday 5 | * Check the LICENSE file that came with this program for licensing terms 6 | */ 7 | 8 | //#include 9 | 10 | #include "scheduler/process.h" 11 | 12 | 13 | uint64_t sys_execve(const char* filename, const char* const* argv, const char* const* envp) { 14 | 15 | } -------------------------------------------------------------------------------- /src/kernel/sys/sys_time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: sys_time.c 3 | * ***************************************************************************** 4 | * Copyright 2021 Scott Maday 5 | * Check the LICENSE file that came with this program for licensing terms 6 | */ 7 | 8 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/dirent.h: -------------------------------------------------------------------------------- 1 | #define _DIRENT_HAVE_D_RECLEN 2 | #define _DIRENT_HAVE_D_OFF 3 | #define _DIRENT_HAVE_D_TYPE 4 | 5 | struct dirent { 6 | ino_t d_ino; 7 | off_t d_off; 8 | unsigned short d_reclen; 9 | unsigned char d_type; 10 | char d_name[256]; 11 | }; 12 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/fenv.h: -------------------------------------------------------------------------------- 1 | #define FE_ALL_EXCEPT 0 2 | #define FE_TONEAREST 0 3 | 4 | typedef unsigned long fexcept_t; 5 | 6 | typedef struct { 7 | unsigned long __cw; 8 | } fenv_t; 9 | 10 | #define FE_DFL_ENV ((const fenv_t *) -1) 11 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/hwcap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/hwcap.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/io.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/io.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/ioctl_fix.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/ioctl_fix.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/ipc.h: -------------------------------------------------------------------------------- 1 | struct ipc_perm { 2 | key_t __ipc_perm_key; 3 | uid_t uid; 4 | gid_t gid; 5 | uid_t cuid; 6 | gid_t cgid; 7 | mode_t mode; 8 | int __ipc_perm_seq; 9 | long __pad1; 10 | long __pad2; 11 | }; 12 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/ipcstat.h: -------------------------------------------------------------------------------- 1 | #define IPC_STAT 2 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/kd.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/limits.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/limits.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/link.h: -------------------------------------------------------------------------------- 1 | typedef uint32_t Elf_Symndx; 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/mman.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/mman.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/msg.h: -------------------------------------------------------------------------------- 1 | struct msqid_ds { 2 | struct ipc_perm msg_perm; 3 | time_t msg_stime; 4 | time_t msg_rtime; 5 | time_t msg_ctime; 6 | unsigned long msg_cbytes; 7 | msgqnum_t msg_qnum; 8 | msglen_t msg_qbytes; 9 | pid_t msg_lspid; 10 | pid_t msg_lrpid; 11 | unsigned long __unused[2]; 12 | }; 13 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/poll.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/poll.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/ptrace.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/ptrace.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/resource.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/sem.h: -------------------------------------------------------------------------------- 1 | struct semid_ds { 2 | struct ipc_perm sem_perm; 3 | time_t sem_otime; 4 | time_t sem_ctime; 5 | #if __BYTE_ORDER == __LITTLE_ENDIAN 6 | unsigned short sem_nsems; 7 | char __sem_nsems_pad[sizeof(long)-sizeof(short)]; 8 | #else 9 | char __sem_nsems_pad[sizeof(long)-sizeof(short)]; 10 | unsigned short sem_nsems; 11 | #endif 12 | long __unused3; 13 | long __unused4; 14 | }; 15 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/bits/socket.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/soundcard.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/statfs.h: -------------------------------------------------------------------------------- 1 | struct statfs { 2 | unsigned long f_type, f_bsize; 3 | fsblkcnt_t f_blocks, f_bfree, f_bavail; 4 | fsfilcnt_t f_files, f_ffree; 5 | fsid_t f_fsid; 6 | unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; 7 | }; 8 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/bits/vt.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/generic/fp_arch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/arch/generic/fp_arch.h -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/bits/limits.h: -------------------------------------------------------------------------------- 1 | #define PAGESIZE 4096 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/bits/mman.h: -------------------------------------------------------------------------------- 1 | #define MAP_32BIT 0x40 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/bits/posix.h: -------------------------------------------------------------------------------- 1 | #define _POSIX_V6_LP64_OFF64 1 2 | #define _POSIX_V7_LP64_OFF64 1 3 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/bits/sem.h: -------------------------------------------------------------------------------- 1 | struct semid_ds { 2 | struct ipc_perm sem_perm; 3 | time_t sem_otime; 4 | long __unused1; 5 | time_t sem_ctime; 6 | long __unused2; 7 | unsigned short sem_nsems; 8 | char __sem_nsems_pad[sizeof(long)-sizeof(short)]; 9 | long __unused3; 10 | long __unused4; 11 | }; 12 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/bits/setjmp.h: -------------------------------------------------------------------------------- 1 | typedef unsigned long __jmp_buf[8]; 2 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/crt_arch.h: -------------------------------------------------------------------------------- 1 | __asm__( 2 | ".text \n" 3 | ".global " START " \n" 4 | START ": \n" 5 | " xor %rbp,%rbp \n" 6 | " mov %rsp,%rdi \n" 7 | ".weak _DYNAMIC \n" 8 | ".hidden _DYNAMIC \n" 9 | " lea _DYNAMIC(%rip),%rsi \n" 10 | " andq $-16,%rsp \n" 11 | " call " START "_c \n" 12 | ); 13 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/ksigaction.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct k_sigaction { 4 | void (*handler)(int); 5 | unsigned long flags; 6 | void (*restorer)(void); 7 | unsigned mask[2]; 8 | }; 9 | 10 | hidden void __restore_rt(); 11 | #define __restore __restore_rt 12 | -------------------------------------------------------------------------------- /src/libraries/musl/arch/x86_64/pthread_arch.h: -------------------------------------------------------------------------------- 1 | static inline uintptr_t __get_tp() 2 | { 3 | uintptr_t tp; 4 | __asm__ ("mov %%fs:0,%0" : "=r" (tp) ); 5 | return tp; 6 | } 7 | 8 | #define MC_PC gregs[REG_RIP] 9 | -------------------------------------------------------------------------------- /src/libraries/musl/include/alloca.h: -------------------------------------------------------------------------------- 1 | #ifndef _ALLOCA_H 2 | #define _ALLOCA_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define __NEED_size_t 9 | #include 10 | 11 | void *alloca(size_t); 12 | 13 | #define alloca __builtin_alloca 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/libraries/musl/include/ar.h: -------------------------------------------------------------------------------- 1 | #ifndef _AR_H 2 | #define _AR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define ARMAG "!\n" 9 | #define SARMAG 8 10 | #define ARFMAG "`\n" 11 | 12 | struct ar_hdr { 13 | char ar_name[16]; 14 | char ar_date[12]; 15 | char ar_uid[6], ar_gid[6]; 16 | char ar_mode[8]; 17 | char ar_size[10]; 18 | char ar_fmag[2]; 19 | }; 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/libraries/musl/include/arpa/nameser_compat.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/crypt.h: -------------------------------------------------------------------------------- 1 | #ifndef _CRYPT_H 2 | #define _CRYPT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | struct crypt_data { 9 | int initialized; 10 | char __buf[256]; 11 | }; 12 | 13 | char *crypt(const char *, const char *); 14 | char *crypt_r(const char *, const char *, struct crypt_data *); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/libraries/musl/include/iso646.h: -------------------------------------------------------------------------------- 1 | #ifndef _ISO646_H 2 | #define _ISO646_H 3 | 4 | #ifndef __cplusplus 5 | 6 | #define and && 7 | #define and_eq &= 8 | #define bitand & 9 | #define bitor | 10 | #define compl ~ 11 | #define not ! 12 | #define not_eq != 13 | #define or || 14 | #define or_eq |= 15 | #define xor ^ 16 | #define xor_eq ^= 17 | 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/libraries/musl/include/lastlog.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/libgen.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBGEN_H 2 | #define _LIBGEN_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | char *dirname(char *); 9 | char *basename(char *); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libraries/musl/include/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/netinet/in_systm.h: -------------------------------------------------------------------------------- 1 | #ifndef _NETINET_IN_SYSTM_H 2 | #define _NETINET_IN_SYSTM_H 3 | 4 | #include 5 | 6 | typedef uint16_t n_short; 7 | typedef uint32_t n_long, n_time; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/include/nl_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _NL_TYPES_H 2 | #define _NL_TYPES_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define NL_SETD 1 9 | #define NL_CAT_LOCALE 1 10 | 11 | typedef int nl_item; 12 | typedef void *nl_catd; 13 | 14 | nl_catd catopen (const char *, int); 15 | char *catgets (nl_catd, int, int, const char *); 16 | int catclose (nl_catd); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/libraries/musl/include/pty.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTY_H 2 | #define _PTY_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | int openpty(int *, int *, char *, const struct termios *, const struct winsize *); 12 | int forkpty(int *, char *, const struct termios *, const struct winsize *); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libraries/musl/include/scsi/scsi_ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCSI_IOCTL_H 2 | #define _SCSI_IOCTL_H 3 | #define SCSI_IOCTL_SEND_COMMAND 1 4 | #define SCSI_IOCTL_TEST_UNIT_READY 2 5 | #define SCSI_IOCTL_BENCHMARK_COMMAND 3 6 | #define SCSI_IOCTL_SYNC 4 7 | #define SCSI_IOCTL_START_UNIT 5 8 | #define SCSI_IOCTL_STOP_UNIT 6 9 | #define SCSI_IOCTL_DOORLOCK 0x5380 10 | #define SCSI_IOCTL_DOORUNLOCK 0x5381 11 | #endif 12 | -------------------------------------------------------------------------------- /src/libraries/musl/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDBOOL_H 2 | #define _STDBOOL_H 3 | 4 | #ifndef __cplusplus 5 | 6 | #define true 1 7 | #define false 0 8 | #define bool _Bool 9 | 10 | #endif 11 | 12 | #define __bool_true_false_are_defined 1 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libraries/musl/include/stdc-predef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDC_PREDEF_H 2 | #define _STDC_PREDEF_H 3 | 4 | #define __STDC_ISO_10646__ 201206L 5 | 6 | #if !defined(__GCC_IEC_559) || __GCC_IEC_559 > 0 7 | #define __STDC_IEC_559__ 1 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/libraries/musl/include/stdnoreturn.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDNORETURN_H 2 | #define _STDNORETURN_H 3 | #ifndef __cplusplus 4 | #include 5 | #define noreturn _Noreturn 6 | #endif 7 | #endif 8 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/auxv.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_AUXV_H 2 | #define _SYS_AUXV_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | unsigned long getauxval(unsigned long); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/dir.h: -------------------------------------------------------------------------------- 1 | #include 2 | #define direct dirent 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/errno.h: -------------------------------------------------------------------------------- 1 | #warning redirecting incorrect #include to 2 | #include 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | #warning redirecting incorrect #include to 2 | #include 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FILE_H 2 | #define _SYS_FILE_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #define LOCK_SH 1 8 | #define LOCK_EX 2 9 | #define LOCK_NB 4 10 | #define LOCK_UN 8 11 | 12 | #define L_SET 0 13 | #define L_INCR 1 14 | #define L_XTND 2 15 | 16 | int flock(int, int); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/fsuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FSUID_H 2 | #define _SYS_FSUID_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define __NEED_uid_t 9 | #define __NEED_gid_t 10 | 11 | #include 12 | 13 | int setfsuid(uid_t); 14 | int setfsgid(gid_t); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_IO_H 2 | #define _SYS_IO_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | 9 | #include 10 | 11 | int iopl(int); 12 | int ioperm(unsigned long, unsigned long, int); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/kd.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/klog.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_KLOG_H 2 | #define _SYS_KLOG_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | int klogctl (int, char *, int); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/poll.h: -------------------------------------------------------------------------------- 1 | #warning redirecting incorrect #include to 2 | #include 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/random.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_RANDOM_H 2 | #define _SYS_RANDOM_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #define __NEED_size_t 8 | #define __NEED_ssize_t 9 | #include 10 | 11 | #define GRND_NONBLOCK 0x0001 12 | #define GRND_RANDOM 0x0002 13 | #define GRND_INSECURE 0x0004 14 | 15 | ssize_t getrandom(void *, size_t, unsigned); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/reg.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_REG_H 2 | #define _SYS_REG_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/sendfile.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_SENDFILE_H 2 | #define _SYS_SENDFILE_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | ssize_t sendfile(int, int, off_t *, size_t); 12 | 13 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 14 | #define sendfile64 sendfile 15 | #define off64_t off_t 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/signal.h: -------------------------------------------------------------------------------- 1 | #warning redirecting incorrect #include to 2 | #include 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/soundcard.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/stropts.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/swap.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_SWAP_H 2 | #define _SYS_SWAP_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | #define SWAP_FLAG_PREFER 0x8000 10 | #define SWAP_FLAG_PRIO_MASK 0x7fff 11 | #define SWAP_FLAG_PRIO_SHIFT 0 12 | #define SWAP_FLAG_DISCARD 0x10000 13 | 14 | int swapon (const char *, int); 15 | int swapoff (const char *); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/syscall.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_SYSCALL_H 2 | #define _SYS_SYSCALL_H 3 | 4 | #include 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/syslog.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/termios.h: -------------------------------------------------------------------------------- 1 | #warning redirecting incorrect #include to 2 | #include 3 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/times.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIMES_H 2 | #define _SYS_TIMES_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define __NEED_clock_t 9 | #include 10 | 11 | struct tms { 12 | clock_t tms_utime; 13 | clock_t tms_stime; 14 | clock_t tms_cutime; 15 | clock_t tms_cstime; 16 | }; 17 | 18 | clock_t times (struct tms *); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/ucontext.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/user.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_USER_H 2 | #define _SYS_USER_H 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/vfs.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/sys/vt.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/syscall.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/libraries/musl/include/ulimit.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULIMIT_H 2 | #define _ULIMIT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define UL_GETFSIZE 1 9 | #define UL_SETFSIZE 2 10 | 11 | long ulimit (int, ...); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/libraries/musl/include/wait.h: -------------------------------------------------------------------------------- 1 | #warning redirecting incorrect #include to 2 | #include 3 | -------------------------------------------------------------------------------- /src/libraries/musl/obj/src/internal/version.h: -------------------------------------------------------------------------------- 1 | #define VERSION "1.2.2" 2 | -------------------------------------------------------------------------------- /src/libraries/musl/src/conf/legacy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int get_nprocs_conf() 5 | { 6 | return sysconf(_SC_NPROCESSORS_CONF); 7 | } 8 | 9 | int get_nprocs() 10 | { 11 | return sysconf(_SC_NPROCESSORS_ONLN); 12 | } 13 | 14 | long get_phys_pages() 15 | { 16 | return sysconf(_SC_PHYS_PAGES); 17 | } 18 | 19 | long get_avphys_pages() 20 | { 21 | return sysconf(_SC_AVPHYS_PAGES); 22 | } 23 | -------------------------------------------------------------------------------- /src/libraries/musl/src/conf/pathconf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long pathconf(const char *path, int name) 4 | { 5 | return fpathconf(-1, name); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/env/__environ.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char **__environ = 0; 4 | weak_alias(__environ, ___environ); 5 | weak_alias(__environ, _environ); 6 | weak_alias(__environ, environ); 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/env/__reset_tls.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pthread_impl.h" 3 | #include "libc.h" 4 | 5 | void __reset_tls() 6 | { 7 | pthread_t self = __pthread_self(); 8 | struct tls_module *p; 9 | size_t i, n = self->dtv[0]; 10 | if (n) for (p=libc.tls_head, i=1; i<=n; i++, p=p->next) { 11 | char *mem = (char *)(self->dtv[i] - DTP_OFFSET); 12 | memcpy(mem, p->image, p->len); 13 | memset(mem+p->len, 0, p->size - p->len); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/env/clearenv.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | static void dummy(char *old, char *new) {} 6 | weak_alias(dummy, __env_rm_add); 7 | 8 | int clearenv() 9 | { 10 | char **e = __environ; 11 | __environ = 0; 12 | if (e) while (*e) __env_rm_add(*e++, 0); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/env/getenv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *getenv(const char *name) 6 | { 7 | size_t l = __strchrnul(name, '=') - name; 8 | if (l && !name[l] && __environ) 9 | for (char **e = __environ; *e; e++) 10 | if (!strncmp(name, *e, l) && l[*e] == '=') 11 | return *e + l+1; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/env/secure_getenv.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "libc.h" 4 | 5 | char *secure_getenv(const char *name) 6 | { 7 | return libc.secure ? NULL : getenv(name); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/errno/__errno_location.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pthread_impl.h" 3 | 4 | int *__errno_location(void) 5 | { 6 | return &__pthread_self()->errno_val; 7 | } 8 | 9 | weak_alias(__errno_location, ___errno_location); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/exit/_Exit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | _Noreturn void _Exit(int ec) 5 | { 6 | __syscall(SYS_exit_group, ec); 7 | for (;;) __syscall(SYS_exit, ec); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/exit/abort_lock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | volatile int __abort_lock[1]; 4 | -------------------------------------------------------------------------------- /src/libraries/musl/src/exit/assert.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | _Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func) 5 | { 6 | fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); 7 | abort(); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/exit/quick_exit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libc.h" 3 | 4 | static void dummy() { } 5 | weak_alias(dummy, __funcs_on_quick_exit); 6 | 7 | _Noreturn void quick_exit(int code) 8 | { 9 | __funcs_on_quick_exit(); 10 | _Exit(code); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/arpa/inet.h: -------------------------------------------------------------------------------- 1 | #ifndef ARPA_INET_H 2 | #define ARPA_INET_H 3 | 4 | #include "../../../include/arpa/inet.h" 5 | 6 | hidden int __inet_aton(const char *, struct in_addr *); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/errno.h: -------------------------------------------------------------------------------- 1 | #ifndef ERRNO_H 2 | #define ERRNO_H 3 | 4 | #include "../../include/errno.h" 5 | 6 | #ifdef __GNUC__ 7 | __attribute__((const)) 8 | #endif 9 | hidden int *___errno_location(void); 10 | 11 | #undef errno 12 | #define errno (*___errno_location()) 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/features.h: -------------------------------------------------------------------------------- 1 | #ifndef FEATURES_H 2 | #define FEATURES_H 3 | 4 | #include "../../include/features.h" 5 | 6 | #define weak __attribute__((__weak__)) 7 | #define hidden __attribute__((__visibility__("hidden"))) 8 | #define weak_alias(old, new) \ 9 | extern __typeof(old) new __attribute__((__weak__, __alias__(#old))) 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/langinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef LANGINFO_H 2 | #define LANGINFO_H 3 | 4 | #include "../../include/langinfo.h" 5 | 6 | char *__nl_langinfo_l(nl_item, locale_t); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNAL_H 2 | #define SIGNAL_H 3 | 4 | #include "../../include/signal.h" 5 | 6 | hidden int __sigaction(int, const struct sigaction *, struct sigaction *); 7 | 8 | hidden void __block_all_sigs(void *); 9 | hidden void __block_app_sigs(void *); 10 | hidden void __restore_sigs(void *); 11 | 12 | hidden void __get_handler_set(sigset_t *); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef STRING_H 2 | #define STRING_H 3 | 4 | #include "../../include/string.h" 5 | 6 | hidden void *__memrchr(const void *, int, size_t); 7 | hidden char *__stpcpy(char *, const char *); 8 | hidden char *__stpncpy(char *, const char *, size_t); 9 | hidden char *__strchrnul(const char *, int); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/sys/auxv.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_AUXV_H 2 | #define SYS_AUXV_H 3 | 4 | #include "../../../include/sys/auxv.h" 5 | 6 | #include 7 | 8 | hidden unsigned long __getauxval(unsigned long); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/sys/membarrier.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_MEMBARRIER_H 2 | #define SYS_MEMBARRIER_H 3 | 4 | #include "../../../include/sys/membarrier.h" 5 | #include 6 | 7 | hidden int __membarrier(int, int); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/sys/sysinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_SYSINFO_H 2 | #define SYS_SYSINFO_H 3 | 4 | #include "../../../include/sys/sysinfo.h" 5 | #include 6 | 7 | hidden int __lsysinfo(struct sysinfo *); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/sys/time.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_TIME_H 2 | #define SYS_TIME_H 3 | 4 | #include "../../../include/sys/time.h" 5 | 6 | hidden int __futimesat(int, const char *, const struct timeval [2]); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef UNISTD_H 2 | #define UNISTD_H 3 | 4 | #include "../../include/unistd.h" 5 | 6 | extern char **__environ; 7 | 8 | hidden int __dup3(int, int, int); 9 | hidden int __mkostemps(char *, int, int); 10 | hidden int __execvpe(const char *, char *const *, char *const *); 11 | hidden off_t __lseek(int, off_t, int); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/include/wchar.h: -------------------------------------------------------------------------------- 1 | #ifndef WCHAR_H 2 | #define WCHAR_H 3 | 4 | #define __DEFINED_struct__IO_FILE 5 | 6 | #include "../../include/wchar.h" 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/aio_impl.h: -------------------------------------------------------------------------------- 1 | #ifndef AIO_IMPL_H 2 | #define AIO_IMPL_H 3 | 4 | extern hidden volatile int __aio_fut; 5 | 6 | extern hidden int __aio_close(int); 7 | extern hidden void __aio_atfork(int); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/defsysinfo.c: -------------------------------------------------------------------------------- 1 | #include "libc.h" 2 | 3 | size_t __sysinfo; 4 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/floatscan.h: -------------------------------------------------------------------------------- 1 | #ifndef FLOATSCAN_H 2 | #define FLOATSCAN_H 3 | 4 | #include 5 | 6 | hidden long double __floatscan(FILE *, int, int); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/intscan.h: -------------------------------------------------------------------------------- 1 | #ifndef INTSCAN_H 2 | #define INTSCAN_H 3 | 4 | #include 5 | 6 | hidden unsigned long long __intscan(FILE *, unsigned, int, unsigned long long); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/ksigaction.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* This is the structure used for the rt_sigaction syscall on most archs, 4 | * but it can be overridden by a file with the same name in the top-level 5 | * arch dir for a given arch, if necessary. */ 6 | struct k_sigaction { 7 | void (*handler)(int); 8 | unsigned long flags; 9 | void (*restorer)(void); 10 | unsigned mask[2]; 11 | }; 12 | 13 | hidden void __restore(), __restore_rt(); 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/libc.c: -------------------------------------------------------------------------------- 1 | #include "libc.h" 2 | 3 | struct __libc __libc; 4 | 5 | size_t __hwcap; 6 | char *__progname=0, *__progname_full=0; 7 | 8 | weak_alias(__progname, program_invocation_short_name); 9 | weak_alias(__progname_full, program_invocation_name); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/lock.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCK_H 2 | #define LOCK_H 3 | 4 | hidden void __lock(volatile int *); 5 | hidden void __unlock(volatile int *); 6 | #define LOCK(x) __lock(x) 7 | #define UNLOCK(x) __unlock(x) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/procfdname.c: -------------------------------------------------------------------------------- 1 | #include "syscall.h" 2 | 3 | void __procfdname(char *buf, unsigned fd) 4 | { 5 | unsigned i, j; 6 | for (i=0; (buf[i] = "/proc/self/fd/"[i]); i++); 7 | if (!fd) { 8 | buf[i] = '0'; 9 | buf[i+1] = 0; 10 | return; 11 | } 12 | for (j=fd; j; j/=10, i++); 13 | buf[i] = 0; 14 | for (; fd; fd/=10) buf[--i] = '0' + fd%10; 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/syscall_ret.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | long __syscall_ret(unsigned long r) 5 | { 6 | if (r > -4096UL) { 7 | errno = -r; 8 | return -1; 9 | } 10 | return r; 11 | } -------------------------------------------------------------------------------- /src/libraries/musl/src/internal/version.c: -------------------------------------------------------------------------------- 1 | #include "version.h" 2 | #include "libc.h" 3 | 4 | const char __libc_version[] = VERSION; 5 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/bind_textdomain_codeset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | char *bind_textdomain_codeset(const char *domainname, const char *codeset) 7 | { 8 | if (codeset && strcasecmp(codeset, "UTF-8")) 9 | errno = EINVAL; 10 | return NULL; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/catclose.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define V(p) be32toh(*(uint32_t *)(p)) 8 | 9 | int catclose (nl_catd catd) 10 | { 11 | char *map = (char *)catd; 12 | munmap(map, V(map+8)+20); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/duplocale.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "locale_impl.h" 4 | #include "libc.h" 5 | 6 | locale_t __duplocale(locale_t old) 7 | { 8 | locale_t new = malloc(sizeof *new); 9 | if (!new) return 0; 10 | if (old == LC_GLOBAL_LOCALE) old = &libc.global_locale; 11 | *new = *old; 12 | return new; 13 | } 14 | 15 | weak_alias(__duplocale, duplocale); 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/freelocale.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "locale_impl.h" 3 | 4 | #define malloc undef 5 | #define calloc undef 6 | #define realloc undef 7 | #define free __libc_free 8 | 9 | void freelocale(locale_t l) 10 | { 11 | if (__loc_is_allocated(l)) free(l); 12 | } 13 | 14 | weak_alias(freelocale, __freelocale); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/iconv_close.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int iconv_close(iconv_t cd) 5 | { 6 | if (!((size_t)cd & 1)) free((void *)cd); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/pleval.h: -------------------------------------------------------------------------------- 1 | #ifndef PLEVAL_H 2 | #define PLEVAL_H 3 | 4 | #include 5 | 6 | hidden unsigned long __pleval(const char *, unsigned long); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/strcoll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "locale_impl.h" 4 | 5 | int __strcoll_l(const char *l, const char *r, locale_t loc) 6 | { 7 | return strcmp(l, r); 8 | } 9 | 10 | int strcoll(const char *l, const char *r) 11 | { 12 | return __strcoll_l(l, r, CURRENT_LOCALE); 13 | } 14 | 15 | weak_alias(__strcoll_l, strcoll_l); 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/locale/wcscoll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "locale_impl.h" 4 | 5 | /* FIXME: stub */ 6 | int __wcscoll_l(const wchar_t *l, const wchar_t *r, locale_t locale) 7 | { 8 | return wcscmp(l, r); 9 | } 10 | 11 | int wcscoll(const wchar_t *l, const wchar_t *r) 12 | { 13 | return __wcscoll_l(l, r, CURRENT_LOCALE); 14 | } 15 | 16 | weak_alias(__wcscoll_l, wcscoll_l); 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__fpclassify.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int __fpclassify(double x) 5 | { 6 | union {double f; uint64_t i;} u = {x}; 7 | int e = u.i>>52 & 0x7ff; 8 | if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; 9 | if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE; 10 | return FP_NORMAL; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__fpclassifyf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int __fpclassifyf(float x) 5 | { 6 | union {float f; uint32_t i;} u = {x}; 7 | int e = u.i>>23 & 0xff; 8 | if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; 9 | if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE; 10 | return FP_NORMAL; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__invtrigl.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* shared by acosl, asinl and atan2l */ 4 | #define pio2_hi __pio2_hi 5 | #define pio2_lo __pio2_lo 6 | hidden extern const long double pio2_hi, pio2_lo; 7 | 8 | hidden long double __invtrigl_R(long double z); 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_divzero.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double __math_divzero(uint32_t sign) 4 | { 5 | return fp_barrier(sign ? -1.0 : 1.0) / 0.0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_divzerof.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | float __math_divzerof(uint32_t sign) 4 | { 5 | return fp_barrierf(sign ? -1.0f : 1.0f) / 0.0f; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_invalid.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double __math_invalid(double x) 4 | { 5 | return (x - x) / (x - x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_invalidf.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | float __math_invalidf(float x) 4 | { 5 | return (x - x) / (x - x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_invalidl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libm.h" 3 | 4 | #if LDBL_MANT_DIG != DBL_MANT_DIG 5 | long double __math_invalidl(long double x) 6 | { 7 | return (x - x) / (x - x); 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_oflow.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double __math_oflow(uint32_t sign) 4 | { 5 | return __math_xflow(sign, 0x1p769); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_oflowf.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | float __math_oflowf(uint32_t sign) 4 | { 5 | return __math_xflowf(sign, 0x1p97f); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_uflow.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double __math_uflow(uint32_t sign) 4 | { 5 | return __math_xflow(sign, 0x1p-767); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_uflowf.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | float __math_uflowf(uint32_t sign) 4 | { 5 | return __math_xflowf(sign, 0x1p-95f); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_xflow.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double __math_xflow(uint32_t sign, double y) 4 | { 5 | return eval_as_double(fp_barrier(sign ? -y : y) * y); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__math_xflowf.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | float __math_xflowf(uint32_t sign, float y) 4 | { 5 | return eval_as_float(fp_barrierf(sign ? -y : y) * y); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__signbit.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | // FIXME: macro in math.h 4 | int __signbit(double x) 5 | { 6 | union { 7 | double d; 8 | uint64_t i; 9 | } y = { x }; 10 | return y.i>>63; 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__signbitf.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | // FIXME: macro in math.h 4 | int __signbitf(float x) 5 | { 6 | union { 7 | float f; 8 | uint32_t i; 9 | } y = { x }; 10 | return y.i>>31; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/__signbitl.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | #if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 4 | int __signbitl(long double x) 5 | { 6 | union ldshape u = {x}; 7 | return u.i.se >> 15; 8 | } 9 | #elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 10 | int __signbitl(long double x) 11 | { 12 | return __signbit(x); 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/copysign.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double copysign(double x, double y) { 4 | union {double f; uint64_t i;} ux={x}, uy={y}; 5 | ux.i &= -1ULL/2; 6 | ux.i |= uy.i & 1ULL<<63; 7 | return ux.f; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/copysignf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | float copysignf(float x, float y) 5 | { 6 | union {float f; uint32_t i;} ux={x}, uy={y}; 7 | ux.i &= 0x7fffffff; 8 | ux.i |= uy.i & 0x80000000; 9 | return ux.f; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fabs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | double fabs(double x) 5 | { 6 | union {double f; uint64_t i;} u = {x}; 7 | u.i &= -1ULL/2; 8 | return u.f; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fabsf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | float fabsf(float x) 5 | { 6 | union {float f; uint32_t i;} u = {x}; 7 | u.i &= 0x7fffffff; 8 | return u.f; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fabsl.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 3 | long double fabsl(long double x) 4 | { 5 | return fabs(x); 6 | } 7 | #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 8 | long double fabsl(long double x) 9 | { 10 | union ldshape u = {x}; 11 | 12 | u.i.se &= 0x7fff; 13 | return u.f; 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fdim.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double fdim(double x, double y) 4 | { 5 | if (isnan(x)) 6 | return x; 7 | if (isnan(y)) 8 | return y; 9 | return x > y ? x - y : 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fdimf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float fdimf(float x, float y) 4 | { 5 | if (isnan(x)) 6 | return x; 7 | if (isnan(y)) 8 | return y; 9 | return x > y ? x - y : 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fdiml.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 5 | long double fdiml(long double x, long double y) 6 | { 7 | return fdim(x, y); 8 | } 9 | #else 10 | long double fdiml(long double x, long double y) 11 | { 12 | if (isnan(x)) 13 | return x; 14 | if (isnan(y)) 15 | return y; 16 | return x > y ? x - y : 0; 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/finite.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | int finite(double x) 5 | { 6 | return isfinite(x); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/finitef.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | int finitef(float x) 5 | { 6 | return isfinite(x); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fmax.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double fmax(double x, double y) 4 | { 5 | if (isnan(x)) 6 | return y; 7 | if (isnan(y)) 8 | return x; 9 | /* handle signed zeros, see C99 Annex F.9.9.2 */ 10 | if (signbit(x) != signbit(y)) 11 | return signbit(x) ? y : x; 12 | return x < y ? y : x; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fmaxf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float fmaxf(float x, float y) 4 | { 5 | if (isnan(x)) 6 | return y; 7 | if (isnan(y)) 8 | return x; 9 | /* handle signed zeroes, see C99 Annex F.9.9.2 */ 10 | if (signbit(x) != signbit(y)) 11 | return signbit(x) ? y : x; 12 | return x < y ? y : x; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fmin.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double fmin(double x, double y) 4 | { 5 | if (isnan(x)) 6 | return y; 7 | if (isnan(y)) 8 | return x; 9 | /* handle signed zeros, see C99 Annex F.9.9.2 */ 10 | if (signbit(x) != signbit(y)) 11 | return signbit(x) ? x : y; 12 | return x < y ? x : y; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/fminf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float fminf(float x, float y) 4 | { 5 | if (isnan(x)) 6 | return y; 7 | if (isnan(y)) 8 | return x; 9 | /* handle signed zeros, see C99 Annex F.9.9.2 */ 10 | if (signbit(x) != signbit(y)) 11 | return signbit(x) ? x : y; 12 | return x < y ? x : y; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/ldexp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double ldexp(double x, int n) 4 | { 5 | return scalbn(x, n); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/ldexpf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float ldexpf(float x, int n) 4 | { 5 | return scalbnf(x, n); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/ldexpl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double ldexpl(long double x, int n) 4 | { 5 | return scalbnl(x, n); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/lgamma.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libm.h" 3 | 4 | double lgamma(double x) 5 | { 6 | return __lgamma_r(x, &__signgam); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/lgammaf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libm.h" 3 | 4 | float lgammaf(float x) 5 | { 6 | return __lgammaf_r(x, &__signgam); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/llrint.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* uses LLONG_MAX > 2^53, see comments in lrint.c */ 4 | 5 | long long llrint(double x) 6 | { 7 | return rint(x); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/llrintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* uses LLONG_MAX > 2^24, see comments in lrint.c */ 4 | 5 | long long llrintf(float x) 6 | { 7 | return rintf(x); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/llround.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long long llround(double x) 4 | { 5 | return round(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/llroundf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long long llroundf(float x) 4 | { 5 | return roundf(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/llroundl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long long llroundl(long double x) 4 | { 5 | return roundl(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/logb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | special cases: 5 | logb(+-0) = -inf, and raise divbyzero 6 | logb(+-inf) = +inf 7 | logb(nan) = nan 8 | */ 9 | 10 | double logb(double x) 11 | { 12 | if (!isfinite(x)) 13 | return x * x; 14 | if (x == 0) 15 | return -1/(x*x); 16 | return ilogb(x); 17 | } 18 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/logbf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float logbf(float x) 4 | { 5 | if (!isfinite(x)) 6 | return x * x; 7 | if (x == 0) 8 | return -1/(x*x); 9 | return ilogbf(x); 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/logbl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 3 | long double logbl(long double x) 4 | { 5 | return logb(x); 6 | } 7 | #else 8 | long double logbl(long double x) 9 | { 10 | if (!isfinite(x)) 11 | return x * x; 12 | if (x == 0) 13 | return -1/(x*x); 14 | return ilogbl(x); 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/lrintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* uses LONG_MAX > 2^24, see comments in lrint.c */ 4 | 5 | long lrintf(float x) 6 | { 7 | return rintf(x); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/lround.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long lround(double x) 4 | { 5 | return round(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/lroundf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long lroundf(float x) 4 | { 5 | return roundf(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/lroundl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long lroundl(long double x) 4 | { 5 | return roundl(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/nan.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double nan(const char *s) 4 | { 5 | return NAN; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/nanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float nanf(const char *s) 4 | { 5 | return NAN; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/nanl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double nanl(const char *s) 4 | { 5 | return NAN; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/nearbyint.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* nearbyint is the same as rint, but it must not raise the inexact exception */ 5 | 6 | double nearbyint(double x) 7 | { 8 | #ifdef FE_INEXACT 9 | #pragma STDC FENV_ACCESS ON 10 | int e; 11 | 12 | e = fetestexcept(FE_INEXACT); 13 | #endif 14 | x = rint(x); 15 | #ifdef FE_INEXACT 16 | if (!e) 17 | feclearexcept(FE_INEXACT); 18 | #endif 19 | return x; 20 | } 21 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/nearbyintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | float nearbyintf(float x) 5 | { 6 | #ifdef FE_INEXACT 7 | #pragma STDC FENV_ACCESS ON 8 | int e; 9 | 10 | e = fetestexcept(FE_INEXACT); 11 | #endif 12 | x = rintf(x); 13 | #ifdef FE_INEXACT 14 | if (!e) 15 | feclearexcept(FE_INEXACT); 16 | #endif 17 | return x; 18 | } 19 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/nexttowardl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double nexttowardl(long double x, long double y) 4 | { 5 | return nextafterl(x, y); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/remainder.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double remainder(double x, double y) 4 | { 5 | int q; 6 | return remquo(x, y, &q); 7 | } 8 | 9 | weak_alias(remainder, drem); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/remainderf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float remainderf(float x, float y) 4 | { 5 | int q; 6 | return remquof(x, y, &q); 7 | } 8 | 9 | weak_alias(remainderf, dremf); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/remainderl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 5 | long double remainderl(long double x, long double y) 6 | { 7 | return remainder(x, y); 8 | } 9 | #else 10 | long double remainderl(long double x, long double y) 11 | { 12 | int q; 13 | return remquol(x, y, &q); 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/scalbln.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | double scalbln(double x, long n) 5 | { 6 | if (n > INT_MAX) 7 | n = INT_MAX; 8 | else if (n < INT_MIN) 9 | n = INT_MIN; 10 | return scalbn(x, n); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/scalblnf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | float scalblnf(float x, long n) 5 | { 6 | if (n > INT_MAX) 7 | n = INT_MAX; 8 | else if (n < INT_MIN) 9 | n = INT_MIN; 10 | return scalbnf(x, n); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/scalblnl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 6 | long double scalblnl(long double x, long n) 7 | { 8 | return scalbln(x, n); 9 | } 10 | #else 11 | long double scalblnl(long double x, long n) 12 | { 13 | if (n > INT_MAX) 14 | n = INT_MAX; 15 | else if (n < INT_MIN) 16 | n = INT_MIN; 17 | return scalbnl(x, n); 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/signgam.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libm.h" 3 | 4 | int __signgam = 0; 5 | 6 | weak_alias(__signgam, signgam); 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/significand.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | double significand(double x) 5 | { 6 | return scalbn(x, -ilogb(x)); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/significandf.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | float significandf(float x) 5 | { 6 | return scalbnf(x, -ilogbf(x)); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/sqrt_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _SQRT_DATA_H 2 | #define _SQRT_DATA_H 3 | 4 | #include 5 | #include 6 | 7 | /* if x in [1,2): i = (int)(64*x); 8 | if x in [2,4): i = (int)(32*x-64); 9 | __rsqrt_tab[i]*2^-16 is estimating 1/sqrt(x) with small relative error: 10 | |__rsqrt_tab[i]*0x1p-16*sqrt(x) - 1| < -0x1.fdp-9 < 2^-8 */ 11 | extern hidden const uint16_t __rsqrt_tab[128]; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/tgammaf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float tgammaf(float x) 4 | { 5 | return tgamma(x); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/trunc.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | double trunc(double x) 4 | { 5 | union {double f; uint64_t i;} u = {x}; 6 | int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12; 7 | uint64_t m; 8 | 9 | if (e >= 52 + 12) 10 | return x; 11 | if (e < 12) 12 | e = 1; 13 | m = -1ULL >> e; 14 | if ((u.i & m) == 0) 15 | return x; 16 | FORCE_EVAL(x + 0x1p120f); 17 | u.i &= ~m; 18 | return u.f; 19 | } 20 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/truncf.c: -------------------------------------------------------------------------------- 1 | #include "libm.h" 2 | 3 | float truncf(float x) 4 | { 5 | union {float f; uint32_t i;} u = {x}; 6 | int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9; 7 | uint32_t m; 8 | 9 | if (e >= 23 + 9) 10 | return x; 11 | if (e < 9) 12 | e = 1; 13 | m = -1U >> e; 14 | if ((u.i & m) == 0) 15 | return x; 16 | FORCE_EVAL(x + 0x1p120f); 17 | u.i &= ~m; 18 | return u.f; 19 | } 20 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/__invtrigl.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/src/math/x86_64/__invtrigl.s -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/acosl.s: -------------------------------------------------------------------------------- 1 | # see ../i386/acos.s 2 | 3 | .global acosl 4 | .type acosl,@function 5 | acosl: 6 | fldt 8(%rsp) 7 | 1: fld %st(0) 8 | fld1 9 | fsub %st(0),%st(1) 10 | fadd %st(2) 11 | fmulp 12 | fsqrt 13 | fabs 14 | fxch %st(1) 15 | fpatan 16 | ret 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/asinl.s: -------------------------------------------------------------------------------- 1 | .global asinl 2 | .type asinl,@function 3 | asinl: 4 | fldt 8(%rsp) 5 | 1: fld %st(0) 6 | fld1 7 | fsub %st(0),%st(1) 8 | fadd %st(2) 9 | fmulp 10 | fsqrt 11 | fpatan 12 | ret 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/atan2l.s: -------------------------------------------------------------------------------- 1 | .global atan2l 2 | .type atan2l,@function 3 | atan2l: 4 | fldt 8(%rsp) 5 | fldt 24(%rsp) 6 | fpatan 7 | ret 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/atanl.s: -------------------------------------------------------------------------------- 1 | .global atanl 2 | .type atanl,@function 3 | atanl: 4 | fldt 8(%rsp) 5 | fld1 6 | fpatan 7 | ret 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/ceill.s: -------------------------------------------------------------------------------- 1 | # see floorl.s 2 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/expm1l.s: -------------------------------------------------------------------------------- 1 | # see exp2l.s 2 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/fabs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double fabs(double x) 4 | { 5 | double t; 6 | __asm__ ("pcmpeqd %0, %0" : "=x"(t)); // t = ~0 7 | __asm__ ("psrlq $1, %0" : "+x"(t)); // t >>= 1 8 | __asm__ ("andps %1, %0" : "+x"(x) : "x"(t)); // x &= t 9 | return x; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/fabsf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float fabsf(float x) 4 | { 5 | float t; 6 | __asm__ ("pcmpeqd %0, %0" : "=x"(t)); // t = ~0 7 | __asm__ ("psrld $1, %0" : "+x"(t)); // t >>= 1 8 | __asm__ ("andps %1, %0" : "+x"(x) : "x"(t)); // x &= t 9 | return x; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/fabsl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double fabsl(long double x) 4 | { 5 | __asm__ ("fabs" : "+t"(x)); 6 | return x; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/fmodl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double fmodl(long double x, long double y) 4 | { 5 | unsigned short fpsr; 6 | do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); 7 | while (fpsr & 0x400); 8 | return x; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/llrint.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long long llrint(double x) 4 | { 5 | long long r; 6 | __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x)); 7 | return r; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/llrintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long long llrintf(float x) 4 | { 5 | long long r; 6 | __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x)); 7 | return r; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/llrintl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long long llrintl(long double x) 4 | { 5 | long long r; 6 | __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st"); 7 | return r; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/log10l.s: -------------------------------------------------------------------------------- 1 | .global log10l 2 | .type log10l,@function 3 | log10l: 4 | fldlg2 5 | fldt 8(%rsp) 6 | fyl2x 7 | ret 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/log1pl.s: -------------------------------------------------------------------------------- 1 | .global log1pl 2 | .type log1pl,@function 3 | log1pl: 4 | mov 14(%rsp),%eax 5 | fldln2 6 | and $0x7fffffff,%eax 7 | fldt 8(%rsp) 8 | cmp $0x3ffd9400,%eax 9 | ja 1f 10 | fyl2xp1 11 | ret 12 | 1: fld1 13 | faddp 14 | fyl2x 15 | ret 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/log2l.s: -------------------------------------------------------------------------------- 1 | .global log2l 2 | .type log2l,@function 3 | log2l: 4 | fld1 5 | fldt 8(%rsp) 6 | fyl2x 7 | ret 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/logl.s: -------------------------------------------------------------------------------- 1 | .global logl 2 | .type logl,@function 3 | logl: 4 | fldln2 5 | fldt 8(%rsp) 6 | fyl2x 7 | ret 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/lrint.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long lrint(double x) 4 | { 5 | long r; 6 | __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x)); 7 | return r; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/lrintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long lrintf(float x) 4 | { 5 | long r; 6 | __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x)); 7 | return r; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/lrintl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long lrintl(long double x) 4 | { 5 | long r; 6 | __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st"); 7 | return r; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/remainderl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double remainderl(long double x, long double y) 4 | { 5 | unsigned short fpsr; 6 | do __asm__ ("fprem1; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y)); 7 | while (fpsr & 0x400); 8 | return x; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/rintl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double rintl(long double x) 4 | { 5 | __asm__ ("frndint" : "+t"(x)); 6 | return x; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/sqrt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double sqrt(double x) 4 | { 5 | __asm__ ("sqrtsd %1, %0" : "=x"(x) : "x"(x)); 6 | return x; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/sqrtf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float sqrtf(float x) 4 | { 5 | __asm__ ("sqrtss %1, %0" : "=x"(x) : "x"(x)); 6 | return x; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/sqrtl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long double sqrtl(long double x) 4 | { 5 | __asm__ ("fsqrt" : "+t"(x)); 6 | return x; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/math/x86_64/truncl.s: -------------------------------------------------------------------------------- 1 | # see floorl.s 2 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/basename.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *basename(char *s) 5 | { 6 | size_t i; 7 | if (!s || !*s) return "."; 8 | i = strlen(s)-1; 9 | for (; i&&s[i]=='/'; i--) s[i] = 0; 10 | for (; i&&s[i-1]!='/'; i--); 11 | return s+i; 12 | } 13 | 14 | weak_alias(basename, __xpg_basename); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/dirname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *dirname(char *s) 5 | { 6 | size_t i; 7 | if (!s || !*s) return "."; 8 | i = strlen(s)-1; 9 | for (; s[i]=='/'; i--) if (!i) return "/"; 10 | for (; s[i]!='/'; i--) if (!i) return "."; 11 | for (; s[i]=='/'; i--) if (!i) return "/"; 12 | s[i+1] = 0; 13 | return s; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/ffs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "atomic.h" 3 | 4 | int ffs(int i) 5 | { 6 | return i ? a_ctz_l(i)+1 : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/ffsl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "atomic.h" 3 | 4 | int ffsl(long i) 5 | { 6 | return i ? a_ctz_l(i)+1 : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/ffsll.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "atomic.h" 3 | 4 | int ffsll(long long i) 5 | { 6 | return i ? a_ctz_64(i)+1 : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/getauxval.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "libc.h" 4 | 5 | unsigned long __getauxval(unsigned long item) 6 | { 7 | size_t *auxv = libc.auxv; 8 | if (item == AT_SECURE) return libc.secure; 9 | for (; *auxv; auxv+=2) 10 | if (*auxv==item) return auxv[1]; 11 | errno = ENOENT; 12 | return 0; 13 | } 14 | 15 | weak_alias(__getauxval, getauxval); 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/getdomainname.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int getdomainname(char *name, size_t len) 8 | { 9 | struct utsname temp; 10 | uname(&temp); 11 | if (!len || strlen(temp.domainname) >= len) { 12 | errno = EINVAL; 13 | return -1; 14 | } 15 | strcpy(name, temp.domainname); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/gethostid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | long gethostid() 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/getpriority.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int getpriority(int which, id_t who) 5 | { 6 | int ret = syscall(SYS_getpriority, which, who); 7 | if (ret < 0) return ret; 8 | return 20-ret; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/getresgid.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "syscall.h" 4 | 5 | int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) 6 | { 7 | return syscall(SYS_getresgid, rgid, egid, sgid); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/getresuid.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "syscall.h" 4 | 5 | int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) 6 | { 7 | return syscall(SYS_getresuid, ruid, euid, suid); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/initgroups.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | int initgroups(const char *user, gid_t gid) 6 | { 7 | gid_t groups[NGROUPS_MAX]; 8 | int count = NGROUPS_MAX; 9 | if (getgrouplist(user, gid, groups, &count) < 0) return -1; 10 | return setgroups(count, groups); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/issetugid.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include "libc.h" 4 | 5 | int issetugid(void) 6 | { 7 | return libc.secure; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/login_tty.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int login_tty(int fd) 6 | { 7 | setsid(); 8 | if (ioctl(fd, TIOCSCTTY, (char *)0)) return -1; 9 | dup2(fd, 0); 10 | dup2(fd, 1); 11 | dup2(fd, 2); 12 | if (fd>2) close(fd); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/ptsname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *ptsname(int fd) 5 | { 6 | static char buf[9 + sizeof(int)*3 + 1]; 7 | int err = __ptsname_r(fd, buf, sizeof buf); 8 | if (err) { 9 | errno = err; 10 | return 0; 11 | } 12 | return buf; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/setdomainname.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "syscall.h" 4 | 5 | int setdomainname(const char *name, size_t len) 6 | { 7 | return syscall(SYS_setdomainname, name, len); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/setpriority.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int setpriority(int which, id_t who, int prio) 5 | { 6 | return syscall(SYS_setpriority, which, who, prio); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/misc/uname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int uname(struct utsname *uts) 5 | { 6 | return syscall(SYS_uname, uts); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/btowc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "internal.h" 5 | 6 | wint_t btowc(int c) 7 | { 8 | int b = (unsigned char)c; 9 | return b<128U ? b : (MB_CUR_MAX==1 && c!=EOF) ? CODEUNIT(c) : WEOF; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/c32rtomb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | size_t c32rtomb(char *restrict s, char32_t c32, mbstate_t *restrict ps) 5 | { 6 | return wcrtomb(s, c32, ps); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/mblen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int mblen(const char *s, size_t n) 4 | { 5 | return mbtowc(0, s, n); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/mbrlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t mbrlen(const char *restrict s, size_t n, mbstate_t *restrict st) 4 | { 5 | static unsigned internal; 6 | return mbrtowc(0, s, n, st ? st : (mbstate_t *)&internal); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/mbrtoc32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps) 5 | { 6 | static unsigned internal_state; 7 | if (!ps) ps = (void *)&internal_state; 8 | if (!s) return mbrtoc32(0, "", 1, ps); 9 | wchar_t wc; 10 | size_t ret = mbrtowc(&wc, s, n, ps); 11 | if (ret <= 4 && pc32) *pc32 = wc; 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/mbsinit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int mbsinit(const mbstate_t *st) 4 | { 5 | return !st || !*(unsigned *)st; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/mbstowcs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | size_t mbstowcs(wchar_t *restrict ws, const char *restrict s, size_t wn) 5 | { 6 | return mbsrtowcs(ws, (void*)&s, wn, 0); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/wcstombs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | size_t wcstombs(char *restrict s, const wchar_t *restrict ws, size_t n) 5 | { 6 | return wcsrtombs(s, &(const wchar_t *){ws}, n, 0); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/wctob.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "internal.h" 5 | 6 | int wctob(wint_t c) 7 | { 8 | if (c < 128U) return c; 9 | if (MB_CUR_MAX==1 && IS_CODEUNIT(c)) return (unsigned char)c; 10 | return EOF; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/multibyte/wctomb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int wctomb(char *s, wchar_t wc) 5 | { 6 | if (!s) return 0; 7 | return wcrtomb(s, wc, 0); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/setjmp/longjmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/src/setjmp/longjmp.c -------------------------------------------------------------------------------- /src/libraries/musl/src/setjmp/setjmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/src/setjmp/setjmp.c -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/kill.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int kill(pid_t pid, int sig) 5 | { 6 | return syscall(SYS_kill, pid, sig); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/killpg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int killpg(pid_t pgid, int sig) 5 | { 6 | if (pgid < 0) { 7 | errno = EINVAL; 8 | return -1; 9 | } 10 | return kill(-pgid, sig); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/psiginfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void psiginfo(const siginfo_t *si, const char *msg) 4 | { 5 | psignal(si->si_signo, msg); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/raise.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | #include "pthread_impl.h" 5 | 6 | int raise(int sig) 7 | { 8 | sigset_t set; 9 | __block_app_sigs(&set); 10 | int ret = syscall(SYS_tkill, __pthread_self()->tid, sig); 11 | __restore_sigs(&set); 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/restore.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* These functions will not work, but suffice for targets where the 4 | * kernel sigaction structure does not actually use sa_restorer. */ 5 | 6 | hidden void __restore() 7 | { 8 | } 9 | 10 | hidden void __restore_rt() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigaddset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sigaddset(sigset_t *set, int sig) 5 | { 6 | unsigned s = sig-1; 7 | if (s >= _NSIG-1 || sig-32U < 3) { 8 | errno = EINVAL; 9 | return -1; 10 | } 11 | set->__bits[s/8/sizeof *set->__bits] |= 1UL<<(s&8*sizeof *set->__bits-1); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigandset.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | #define SST_SIZE (_NSIG/8/sizeof(long)) 5 | 6 | int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right) 7 | { 8 | unsigned long i = 0, *d = (void*) dest, *l = (void*) left, *r = (void*) right; 9 | for(; i < SST_SIZE; i++) d[i] = l[i] & r[i]; 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigdelset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sigdelset(sigset_t *set, int sig) 5 | { 6 | unsigned s = sig-1; 7 | if (s >= _NSIG-1 || sig-32U < 3) { 8 | errno = EINVAL; 9 | return -1; 10 | } 11 | set->__bits[s/8/sizeof *set->__bits] &=~(1UL<<(s&8*sizeof *set->__bits-1)); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigemptyset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sigemptyset(sigset_t *set) 5 | { 6 | set->__bits[0] = 0; 7 | if (sizeof(long)==4 || _NSIG > 65) set->__bits[1] = 0; 8 | if (sizeof(long)==4 && _NSIG > 65) { 9 | set->__bits[2] = 0; 10 | set->__bits[3] = 0; 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sighold.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sighold(int sig) 4 | { 5 | sigset_t mask; 6 | 7 | sigemptyset(&mask); 8 | if (sigaddset(&mask, sig) < 0) return -1; 9 | return sigprocmask(SIG_BLOCK, &mask, 0); 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigignore.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigignore(int sig) 4 | { 5 | struct sigaction sa; 6 | 7 | sigemptyset(&sa.sa_mask); 8 | sa.sa_handler = SIG_IGN; 9 | sa.sa_flags = 0; 10 | return sigaction(sig, &sa, 0); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/siginterrupt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int siginterrupt(int sig, int flag) 4 | { 5 | struct sigaction sa; 6 | 7 | sigaction(sig, 0, &sa); 8 | if (flag) sa.sa_flags &= ~SA_RESTART; 9 | else sa.sa_flags |= SA_RESTART; 10 | 11 | return sigaction(sig, &sa, 0); 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigisemptyset.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | int sigisemptyset(const sigset_t *set) 6 | { 7 | for (size_t i=0; i<_NSIG/8/sizeof *set->__bits; i++) 8 | if (set->__bits[i]) return 0; 9 | return 1; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigismember.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigismember(const sigset_t *set, int sig) 4 | { 5 | unsigned s = sig-1; 6 | if (s >= _NSIG-1) return 0; 7 | return !!(set->__bits[s/8/sizeof *set->__bits] & 1UL<<(s&8*sizeof *set->__bits-1)); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/siglongjmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | #include "pthread_impl.h" 5 | 6 | _Noreturn void siglongjmp(sigjmp_buf buf, int ret) 7 | { 8 | longjmp(buf, ret); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | void (*signal(int sig, void (*func)(int)))(int) 5 | { 6 | struct sigaction sa_old, sa = { .sa_handler = func, .sa_flags = SA_RESTART }; 7 | if (__sigaction(sig, &sa, &sa_old) < 0) 8 | return SIG_ERR; 9 | return sa_old.sa_handler; 10 | } 11 | 12 | weak_alias(signal, bsd_signal); 13 | weak_alias(signal, __sysv_signal); 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigorset.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | #define SST_SIZE (_NSIG/8/sizeof(long)) 5 | 6 | int sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *right) 7 | { 8 | unsigned long i = 0, *d = (void*) dest, *l = (void*) left, *r = (void*) right; 9 | for(; i < SST_SIZE; i++) d[i] = l[i] | r[i]; 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigpause.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigpause(int sig) 4 | { 5 | sigset_t mask; 6 | sigprocmask(0, 0, &mask); 7 | sigdelset(&mask, sig); 8 | return sigsuspend(&mask); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigpending.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int sigpending(sigset_t *set) 5 | { 6 | return syscall(SYS_rt_sigpending, set, _NSIG/8); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigprocmask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old) 5 | { 6 | int r = pthread_sigmask(how, set, old); 7 | if (!r) return r; 8 | errno = r; 9 | return -1; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigrelse.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigrelse(int sig) 4 | { 5 | sigset_t mask; 6 | 7 | sigemptyset(&mask); 8 | if (sigaddset(&mask, sig) < 0) return -1; 9 | return sigprocmask(SIG_UNBLOCK, &mask, 0); 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigrtmax.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int __libc_current_sigrtmax() 4 | { 5 | return _NSIG-1; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigrtmin.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int __libc_current_sigrtmin() 4 | { 5 | return 35; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigsetjmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/src/signal/sigsetjmp.c -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigsetjmp_tail.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | hidden int __sigsetjmp_tail(sigjmp_buf jb, int ret) 6 | { 7 | void *p = jb->__ss; 8 | __syscall(SYS_rt_sigprocmask, SIG_SETMASK, ret?p:0, ret?0:p, _NSIG/8); 9 | return ret; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigsuspend.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int sigsuspend(const sigset_t *mask) 5 | { 6 | return syscall_cp(SYS_rt_sigsuspend, mask, _NSIG/8); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigwait.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigwait(const sigset_t *restrict mask, int *restrict sig) 4 | { 5 | siginfo_t si; 6 | if (sigtimedwait(mask, &si, 0) < 0) 7 | return -1; 8 | *sig = si.si_signo; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/sigwaitinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigwaitinfo(const sigset_t *restrict mask, siginfo_t *restrict si) 4 | { 5 | return sigtimedwait(mask, si, 0); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/signal/x86_64/restore.s: -------------------------------------------------------------------------------- 1 | nop 2 | .global __restore_rt 3 | .hidden __restore_rt 4 | .type __restore_rt,@function 5 | __restore_rt: 6 | mov $15, %rax 7 | syscall 8 | .size __restore_rt,.-__restore_rt 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/__fclose_ca.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int __fclose_ca(FILE *f) 4 | { 5 | return f->close(f); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/__overflow.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int __overflow(FILE *f, int _c) 4 | { 5 | unsigned char c = _c; 6 | if (!f->wend && __towrite(f)) return EOF; 7 | if (f->wpos != f->wend && c != f->lbf) return *f->wpos++ = c; 8 | if (f->write(f, &c, 1)!=1) return EOF; 9 | return c; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/__stdio_close.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include "aio_impl.h" 3 | 4 | static int dummy(int fd) 5 | { 6 | return fd; 7 | } 8 | 9 | weak_alias(dummy, __aio_close); 10 | 11 | int __stdio_close(FILE *f) 12 | { 13 | return syscall(SYS_close, __aio_close(f->fd)); 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/__stdio_seek.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | off_t __stdio_seek(FILE *f, off_t off, int whence) 5 | { 6 | return __lseek(f->fd, off, whence); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/__stdout_write.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) 5 | { 6 | struct winsize wsz; 7 | f->write = __stdio_write; 8 | if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz)) 9 | f->lbf = -1; 10 | return __stdio_write(f, buf, len); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/__uflow.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | /* This function assumes it will never be called if there is already 4 | * data buffered for reading. */ 5 | 6 | int __uflow(FILE *f) 7 | { 8 | unsigned char c; 9 | if (!__toread(f) && f->read(f, &c, 1)==1) return c; 10 | return EOF; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/asprintf.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | int asprintf(char **s, const char *fmt, ...) 6 | { 7 | int ret; 8 | va_list ap; 9 | va_start(ap, fmt); 10 | ret = vasprintf(s, fmt, ap); 11 | va_end(ap); 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/clearerr.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | void clearerr(FILE *f) 4 | { 5 | FLOCK(f); 6 | f->flags &= ~(F_EOF|F_ERR); 7 | FUNLOCK(f); 8 | } 9 | 10 | weak_alias(clearerr, clearerr_unlocked); 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/dprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int dprintf(int fd, const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vdprintf(fd, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/feof.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | #undef feof 4 | 5 | int feof(FILE *f) 6 | { 7 | FLOCK(f); 8 | int ret = !!(f->flags & F_EOF); 9 | FUNLOCK(f); 10 | return ret; 11 | } 12 | 13 | weak_alias(feof, feof_unlocked); 14 | weak_alias(feof, _IO_feof_unlocked); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/ferror.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | #undef ferror 4 | 5 | int ferror(FILE *f) 6 | { 7 | FLOCK(f); 8 | int ret = !!(f->flags & F_ERR); 9 | FUNLOCK(f); 10 | return ret; 11 | } 12 | 13 | weak_alias(ferror, ferror_unlocked); 14 | weak_alias(ferror, _IO_ferror_unlocked); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fgetc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "getc.h" 3 | 4 | int fgetc(FILE *f) 5 | { 6 | return do_getc(f); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fgetpos.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int fgetpos(FILE *restrict f, fpos_t *restrict pos) 4 | { 5 | off_t off = __ftello(f); 6 | if (off < 0) return -1; 7 | *(long long *)pos = off; 8 | return 0; 9 | } 10 | 11 | weak_alias(fgetpos, fgetpos64); 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fileno.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | int fileno(FILE *f) 5 | { 6 | FLOCK(f); 7 | int fd = f->fd; 8 | FUNLOCK(f); 9 | if (fd < 0) { 10 | errno = EBADF; 11 | return -1; 12 | } 13 | return fd; 14 | } 15 | 16 | weak_alias(fileno, fileno_unlocked); 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/flockfile.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include "pthread_impl.h" 3 | 4 | void flockfile(FILE *f) 5 | { 6 | if (!ftrylockfile(f)) return; 7 | __lockfile(f); 8 | __register_locked_file(f, __pthread_self()); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fprintf(FILE *restrict f, const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vfprintf(f, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fputc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "putc.h" 3 | 4 | int fputc(int c, FILE *f) 5 | { 6 | return do_putc(c, f); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fputs.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | int fputs(const char *restrict s, FILE *restrict f) 5 | { 6 | size_t l = strlen(s); 7 | return (fwrite(s, 1, l, f)==l) - 1; 8 | } 9 | 10 | weak_alias(fputs, fputs_unlocked); 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fscanf(FILE *restrict f, const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vfscanf(f, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | 14 | weak_alias(fscanf, __isoc99_fscanf); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fsetpos.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int fsetpos(FILE *f, const fpos_t *pos) 4 | { 5 | return __fseeko(f, *(const long long *)pos, SEEK_SET); 6 | } 7 | 8 | weak_alias(fsetpos, fsetpos64); 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/funlockfile.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include "pthread_impl.h" 3 | 4 | void funlockfile(FILE *f) 5 | { 6 | if (f->lockcount == 1) { 7 | __unlist_locked_file(f); 8 | f->lockcount = 0; 9 | __unlockfile(f); 10 | } else { 11 | f->lockcount--; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fwide.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stdio_impl.h" 3 | #include "locale_impl.h" 4 | 5 | int fwide(FILE *f, int mode) 6 | { 7 | FLOCK(f); 8 | if (mode) { 9 | if (!f->locale) f->locale = MB_CUR_MAX==1 10 | ? C_LOCALE : UTF8_LOCALE; 11 | if (!f->mode) f->mode = mode>0 ? 1 : -1; 12 | } 13 | mode = f->mode; 14 | FUNLOCK(f); 15 | return mode; 16 | } 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fwprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int fwprintf(FILE *restrict f, const wchar_t *restrict fmt, ...) 6 | { 7 | int ret; 8 | va_list ap; 9 | va_start(ap, fmt); 10 | ret = vfwprintf(f, fmt, ap); 11 | va_end(ap); 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/fwscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int fwscanf(FILE *restrict f, const wchar_t *restrict fmt, ...) 6 | { 7 | int ret; 8 | va_list ap; 9 | va_start(ap, fmt); 10 | ret = vfwscanf(f, fmt, ap); 11 | va_end(ap); 12 | return ret; 13 | } 14 | 15 | weak_alias(fwscanf,__isoc99_fwscanf); 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "getc.h" 3 | 4 | int getc(FILE *f) 5 | { 6 | return do_getc(f); 7 | } 8 | 9 | weak_alias(getc, _IO_getc); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getc_unlocked.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int (getc_unlocked)(FILE *f) 4 | { 5 | return getc_unlocked(f); 6 | } 7 | 8 | weak_alias (getc_unlocked, fgetc_unlocked); 9 | weak_alias (getc_unlocked, _IO_getc_unlocked); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "getc.h" 3 | 4 | int getchar(void) 5 | { 6 | return do_getc(stdin); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getchar_unlocked.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int getchar_unlocked(void) 4 | { 5 | return getc_unlocked(stdin); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getline.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | ssize_t getline(char **restrict s, size_t *restrict n, FILE *restrict f) 4 | { 5 | return getdelim(s, n, '\n', f); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/gets.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | #include 4 | 5 | char *gets(char *s) 6 | { 7 | size_t i=0; 8 | int c; 9 | FLOCK(stdin); 10 | while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c; 11 | s[i] = 0; 12 | if (c != '\n' && (!feof(stdin) || !i)) s = 0; 13 | FUNLOCK(stdin); 14 | return s; 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getw.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | int getw(FILE *f) 5 | { 6 | int x; 7 | return fread(&x, sizeof x, 1, f) ? x : EOF; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getwc.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | wint_t getwc(FILE *f) 5 | { 6 | return fgetwc(f); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/getwchar.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | wint_t getwchar(void) 5 | { 6 | return fgetwc(stdin); 7 | } 8 | 9 | weak_alias(getwchar, getwchar_unlocked); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/ofl.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include "lock.h" 3 | #include "fork_impl.h" 4 | 5 | static FILE *ofl_head; 6 | static volatile int ofl_lock[1]; 7 | volatile int *const __stdio_ofl_lockptr = ofl_lock; 8 | 9 | FILE **__ofl_lock() 10 | { 11 | LOCK(ofl_lock); 12 | return &ofl_head; 13 | } 14 | 15 | void __ofl_unlock() 16 | { 17 | UNLOCK(ofl_lock); 18 | } 19 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/ofl_add.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | FILE *__ofl_add(FILE *f) 4 | { 5 | FILE **head = __ofl_lock(); 6 | f->next = *head; 7 | if (*head) (*head)->prev = f; 8 | *head = f; 9 | __ofl_unlock(); 10 | return f; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/pclose.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | #include 4 | 5 | int pclose(FILE *f) 6 | { 7 | int status, r; 8 | pid_t pid = f->pipe_pid; 9 | fclose(f); 10 | while ((r=__syscall(SYS_wait4, pid, &status, 0, 0)) == -EINTR); 11 | if (r<0) return __syscall_ret(r); 12 | return status; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int printf(const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vfprintf(stdout, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "putc.h" 3 | 4 | int putc(int c, FILE *f) 5 | { 6 | return do_putc(c, f); 7 | } 8 | 9 | weak_alias(putc, _IO_putc); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putc_unlocked.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int (putc_unlocked)(int c, FILE *f) 4 | { 5 | return putc_unlocked(c, f); 6 | } 7 | 8 | weak_alias(putc_unlocked, fputc_unlocked); 9 | weak_alias(putc_unlocked, _IO_putc_unlocked); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "putc.h" 3 | 4 | int putchar(int c) 5 | { 6 | return do_putc(c, stdout); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putchar_unlocked.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int putchar_unlocked(int c) 4 | { 5 | return putc_unlocked(c, stdout); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/puts.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int puts(const char *s) 4 | { 5 | int r; 6 | FLOCK(stdout); 7 | r = -(fputs(s, stdout) < 0 || putc_unlocked('\n', stdout) < 0); 8 | FUNLOCK(stdout); 9 | return r; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putw.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | int putw(int x, FILE *f) 5 | { 6 | return (int)fwrite(&x, sizeof x, 1, f)-1; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putwc.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | wint_t putwc(wchar_t c, FILE *f) 5 | { 6 | return fputwc(c, f); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/putwchar.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | #include 3 | 4 | wint_t putwchar(wchar_t c) 5 | { 6 | return fputwc(c, stdout); 7 | } 8 | 9 | weak_alias(putwchar, putwchar_unlocked); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/rename.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int rename(const char *old, const char *new) 6 | { 7 | #if defined(SYS_rename) 8 | return syscall(SYS_rename, old, new); 9 | #elif defined(SYS_renameat) 10 | return syscall(SYS_renameat, AT_FDCWD, old, AT_FDCWD, new); 11 | #else 12 | return syscall(SYS_renameat2, AT_FDCWD, old, AT_FDCWD, new, 0); 13 | #endif 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/rewind.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | void rewind(FILE *f) 4 | { 5 | FLOCK(f); 6 | __fseeko_unlocked(f, 0, SEEK_SET); 7 | f->flags &= ~F_ERR; 8 | FUNLOCK(f); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/scanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int scanf(const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vscanf(fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | 14 | weak_alias(scanf,__isoc99_scanf); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/setbuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void setbuf(FILE *restrict f, char *restrict buf) 4 | { 5 | setvbuf(f, buf, buf ? _IOFBF : _IONBF, BUFSIZ); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/setbuffer.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | void setbuffer(FILE *f, char *buf, size_t size) 5 | { 6 | setvbuf(f, buf, buf ? _IOFBF : _IONBF, size); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/setlinebuf.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | void setlinebuf(FILE *f) 5 | { 6 | setvbuf(f, 0, _IOLBF, 0); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/snprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int snprintf(char *restrict s, size_t n, const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vsnprintf(s, n, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/sprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sprintf(char *restrict s, const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vsprintf(s, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/sscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sscanf(const char *restrict s, const char *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vsscanf(s, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | 14 | weak_alias(sscanf,__isoc99_sscanf); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/swprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int swprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vswprintf(s, n, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/swscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int swscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, ...) 5 | { 6 | int ret; 7 | va_list ap; 8 | va_start(ap, fmt); 9 | ret = vswscanf(s, fmt, ap); 10 | va_end(ap); 11 | return ret; 12 | } 13 | 14 | weak_alias(swscanf,__isoc99_swscanf); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/ungetc.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int ungetc(int c, FILE *f) 4 | { 5 | if (c == EOF) return c; 6 | 7 | FLOCK(f); 8 | 9 | if (!f->rpos) __toread(f); 10 | if (!f->rpos || f->rpos <= f->buf - UNGET) { 11 | FUNLOCK(f); 12 | return EOF; 13 | } 14 | 15 | *--f->rpos = c; 16 | f->flags &= ~F_EOF; 17 | 18 | FUNLOCK(f); 19 | return (unsigned char)c; 20 | } 21 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vasprintf.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | #include 5 | 6 | int vasprintf(char **s, const char *fmt, va_list ap) 7 | { 8 | va_list ap2; 9 | va_copy(ap2, ap); 10 | int l = vsnprintf(0, 0, fmt, ap2); 11 | va_end(ap2); 12 | 13 | if (l<0 || !(*s=malloc(l+1U))) return -1; 14 | return vsnprintf(*s, l+1U, fmt, ap); 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vdprintf.c: -------------------------------------------------------------------------------- 1 | #include "stdio_impl.h" 2 | 3 | int vdprintf(int fd, const char *restrict fmt, va_list ap) 4 | { 5 | FILE f = { 6 | .fd = fd, .lbf = EOF, .write = __stdio_write, 7 | .buf = (void *)fmt, .buf_size = 0, 8 | .lock = -1 9 | }; 10 | return vfprintf(&f, fmt, ap); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int vprintf(const char *restrict fmt, va_list ap) 4 | { 5 | return vfprintf(stdout, fmt, ap); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vscanf(const char *restrict fmt, va_list ap) 5 | { 6 | return vfscanf(stdin, fmt, ap); 7 | } 8 | 9 | weak_alias(vscanf,__isoc99_vscanf); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vsprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vsprintf(char *restrict s, const char *restrict fmt, va_list ap) 5 | { 6 | return vsnprintf(s, INT_MAX, fmt, ap); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vwprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vwprintf(const wchar_t *restrict fmt, va_list ap) 5 | { 6 | return vfwprintf(stdout, fmt, ap); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/vwscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int vwscanf(const wchar_t *restrict fmt, va_list ap) 6 | { 7 | return vfwscanf(stdin, fmt, ap); 8 | } 9 | 10 | weak_alias(vwscanf,__isoc99_vwscanf); 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/wprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int wprintf(const wchar_t *restrict fmt, ...) 6 | { 7 | int ret; 8 | va_list ap; 9 | va_start(ap, fmt); 10 | ret = vwprintf(fmt, ap); 11 | va_end(ap); 12 | return ret; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/stdio/wscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int wscanf(const wchar_t *restrict fmt, ...) 6 | { 7 | int ret; 8 | va_list ap; 9 | va_start(ap, fmt); 10 | ret = vwscanf(fmt, ap); 11 | va_end(ap); 12 | return ret; 13 | } 14 | 15 | weak_alias(wscanf,__isoc99_wscanf); 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/bcmp.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | 5 | int bcmp(const void *s1, const void *s2, size_t n) 6 | { 7 | return memcmp(s1, s2, n); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/bcopy.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | 5 | void bcopy(const void *s1, void *s2, size_t n) 6 | { 7 | memmove(s2, s1, n); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/bzero.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | 5 | void bzero(void *s, size_t n) 6 | { 7 | memset(s, 0, n); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/explicit_bzero.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | 4 | void explicit_bzero(void *d, size_t n) 5 | { 6 | d = memset(d, 0, n); 7 | __asm__ __volatile__ ("" : : "r"(d) : "memory"); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/index.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | 5 | char *index(const char *s, int c) 6 | { 7 | return strchr(s, c); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/memcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int memcmp(const void *vl, const void *vr, size_t n) 4 | { 5 | const unsigned char *l=vl, *r=vr; 6 | for (; n && *l == *r; n--, l++, r++); 7 | return n ? *l-*r : 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/mempcpy.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | void *mempcpy(void *dest, const void *src, size_t n) 5 | { 6 | return (char *)memcpy(dest, src, n) + n; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/memrchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void *__memrchr(const void *m, int c, size_t n) 4 | { 5 | const unsigned char *s = m; 6 | c = (unsigned char)c; 7 | while (n--) if (s[n]==c) return (void *)(s+n); 8 | return 0; 9 | } 10 | 11 | weak_alias(__memrchr, memrchr); 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/rindex.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | 5 | char *rindex(const char *s, int c) 6 | { 7 | return strrchr(s, c); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strcasestr.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | char *strcasestr(const char *h, const char *n) 5 | { 6 | size_t l = strlen(n); 7 | for (; *h; h++) if (!strncasecmp(h, n, l)) return (char *)h; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strcat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strcat(char *restrict dest, const char *restrict src) 4 | { 5 | strcpy(dest + strlen(dest), src); 6 | return dest; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strchr(const char *s, int c) 4 | { 5 | char *r = __strchrnul(s, c); 6 | return *(unsigned char *)r == (unsigned char)c ? r : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int strcmp(const char *l, const char *r) 4 | { 5 | for (; *l==*r && *l; l++, r++); 6 | return *(unsigned char *)l - *(unsigned char *)r; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strcpy(char *restrict dest, const char *restrict src) 4 | { 5 | __stpcpy(dest, src); 6 | return dest; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strdup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *strdup(const char *s) 5 | { 6 | size_t l = strlen(s); 7 | char *d = malloc(l+1); 8 | if (!d) return NULL; 9 | return memcpy(d, s, l+1); 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strerror_r.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int strerror_r(int err, char *buf, size_t buflen) 5 | { 6 | char *msg = strerror(err); 7 | size_t l = strlen(msg); 8 | if (l >= buflen) { 9 | if (buflen) { 10 | memcpy(buf, msg, buflen-1); 11 | buf[buflen-1] = 0; 12 | } 13 | return ERANGE; 14 | } 15 | memcpy(buf, msg, l+1); 16 | return 0; 17 | } 18 | 19 | weak_alias(strerror_r, __xpg_strerror_r); 20 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strlcat.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | 4 | size_t strlcat(char *d, const char *s, size_t n) 5 | { 6 | size_t l = strnlen(d, n); 7 | if (l == n) return l + strlen(s); 8 | return l + strlcpy(d+l, s, n-l); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strncat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strncat(char *restrict d, const char *restrict s, size_t n) 4 | { 5 | char *a = d; 6 | d += strlen(d); 7 | while (n && *s) n--, *d++ = *s++; 8 | *d++ = 0; 9 | return a; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strncmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int strncmp(const char *_l, const char *_r, size_t n) 4 | { 5 | const unsigned char *l=(void *)_l, *r=(void *)_r; 6 | if (!n--) return 0; 7 | for (; *l && *r && n && *l == *r ; l++, r++, n--); 8 | return *l - *r; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strncpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strncpy(char *restrict d, const char *restrict s, size_t n) 4 | { 5 | __stpncpy(d, s, n); 6 | return d; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strndup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *strndup(const char *s, size_t n) 5 | { 6 | size_t l = strnlen(s, n); 7 | char *d = malloc(l+1); 8 | if (!d) return NULL; 9 | memcpy(d, s, l); 10 | d[l] = 0; 11 | return d; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strnlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t strnlen(const char *s, size_t n) 4 | { 5 | const char *p = memchr(s, 0, n); 6 | return p ? p-s : n; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strpbrk.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strpbrk(const char *s, const char *b) 4 | { 5 | s += strcspn(s, b); 6 | return *s ? (char *)s : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strrchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strrchr(const char *s, int c) 4 | { 5 | return __memrchr(s, c, strlen(s) + 1); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strsep.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | char *strsep(char **str, const char *sep) 5 | { 6 | char *s = *str, *end; 7 | if (!s) return NULL; 8 | end = s + strcspn(s, sep); 9 | if (*end) *end++ = 0; 10 | else end = 0; 11 | *str = end; 12 | return s; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strtok.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strtok(char *restrict s, const char *restrict sep) 4 | { 5 | static char *p; 6 | if (!s && !(s = p)) return NULL; 7 | s += strspn(s, sep); 8 | if (!*s) return p = 0; 9 | p = s + strcspn(s, sep); 10 | if (*p) *p++ = 0; 11 | else p = 0; 12 | return s; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/strtok_r.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strtok_r(char *restrict s, const char *restrict sep, char **restrict p) 4 | { 5 | if (!s && !(s = *p)) return NULL; 6 | s += strspn(s, sep); 7 | if (!*s) return *p = 0; 8 | *p = s + strcspn(s, sep); 9 | if (**p) *(*p)++ = 0; 10 | else *p = 0; 11 | return s; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/swab.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void swab(const void *restrict _src, void *restrict _dest, ssize_t n) 4 | { 5 | const char *src = _src; 6 | char *dest = _dest; 7 | for (; n>1; n-=2) { 8 | dest[0] = src[1]; 9 | dest[1] = src[0]; 10 | dest += 2; 11 | src += 2; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcpcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcpcpy(wchar_t *restrict d, const wchar_t *restrict s) 4 | { 5 | return wcscpy(d, s) + wcslen(s); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcpncpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcpncpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) 4 | { 5 | return wcsncpy(d, s, n) + wcsnlen(s, n); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcscasecmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int wcscasecmp(const wchar_t *l, const wchar_t *r) 5 | { 6 | return wcsncasecmp(l, r, -1); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcscasecmp_l.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int wcscasecmp_l(const wchar_t *l, const wchar_t *r, locale_t locale) 4 | { 5 | return wcscasecmp(l, r); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcscat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcscat(wchar_t *restrict dest, const wchar_t *restrict src) 4 | { 5 | wcscpy(dest + wcslen(dest), src); 6 | return dest; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcschr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcschr(const wchar_t *s, wchar_t c) 4 | { 5 | if (!c) return (wchar_t *)s + wcslen(s); 6 | for (; *s && *s != c; s++); 7 | return *s ? (wchar_t *)s : 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcscmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int wcscmp(const wchar_t *l, const wchar_t *r) 4 | { 5 | for (; *l==*r && *l && *r; l++, r++); 6 | return *l - *r; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcscpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcscpy(wchar_t *restrict d, const wchar_t *restrict s) 4 | { 5 | wchar_t *a = d; 6 | while ((*d++ = *s++)); 7 | return a; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcscspn.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t wcscspn(const wchar_t *s, const wchar_t *c) 4 | { 5 | const wchar_t *a; 6 | if (!c[0]) return wcslen(s); 7 | if (!c[1]) return (s=wcschr(a=s, *c)) ? s-a : wcslen(a); 8 | for (a=s; *s && !wcschr(c, *s); s++); 9 | return s-a; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsdup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | wchar_t *wcsdup(const wchar_t *s) 5 | { 6 | size_t l = wcslen(s); 7 | wchar_t *d = malloc((l+1)*sizeof(wchar_t)); 8 | if (!d) return NULL; 9 | return wmemcpy(d, s, l+1); 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcslen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t wcslen(const wchar_t *s) 4 | { 5 | const wchar_t *a; 6 | for (a=s; *s; s++); 7 | return s-a; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsncasecmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int wcsncasecmp(const wchar_t *l, const wchar_t *r, size_t n) 5 | { 6 | if (!n--) return 0; 7 | for (; *l && *r && n && (*l == *r || towlower(*l) == towlower(*r)); l++, r++, n--); 8 | return towlower(*l) - towlower(*r); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsncasecmp_l.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int wcsncasecmp_l(const wchar_t *l, const wchar_t *r, size_t n, locale_t locale) 4 | { 5 | return wcsncasecmp(l, r, n); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsncat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcsncat(wchar_t *restrict d, const wchar_t *restrict s, size_t n) 4 | { 5 | wchar_t *a = d; 6 | d += wcslen(d); 7 | while (n && *s) n--, *d++ = *s++; 8 | *d++ = 0; 9 | return a; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsncmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int wcsncmp(const wchar_t *l, const wchar_t *r, size_t n) 4 | { 5 | for (; n && *l==*r && *l && *r; n--, l++, r++); 6 | return n ? *l - *r : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsncpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcsncpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) 4 | { 5 | wchar_t *a = d; 6 | while (n && *s) n--, *d++ = *s++; 7 | wmemset(d, 0, n); 8 | return a; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsnlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t wcsnlen(const wchar_t *s, size_t n) 4 | { 5 | const wchar_t *z = wmemchr(s, 0, n); 6 | if (z) n = z-s; 7 | return n; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcspbrk.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcspbrk(const wchar_t *s, const wchar_t *b) 4 | { 5 | s += wcscspn(s, b); 6 | return *s ? (wchar_t *)s : NULL; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsrchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcsrchr(const wchar_t *s, wchar_t c) 4 | { 5 | const wchar_t *p; 6 | for (p=s+wcslen(s); p>=s && *p!=c; p--); 7 | return p>=s ? (wchar_t *)p : 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcsspn.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t wcsspn(const wchar_t *s, const wchar_t *c) 4 | { 5 | const wchar_t *a; 6 | for (a=s; *s && wcschr(c, *s); s++); 7 | return s-a; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcstok.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcstok(wchar_t *restrict s, const wchar_t *restrict sep, wchar_t **restrict p) 4 | { 5 | if (!s && !(s = *p)) return NULL; 6 | s += wcsspn(s, sep); 7 | if (!*s) return *p = 0; 8 | *p = s + wcscspn(s, sep); 9 | if (**p) *(*p)++ = 0; 10 | else *p = 0; 11 | return s; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wcswcs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wcswcs(const wchar_t *haystack, const wchar_t *needle) 4 | { 5 | return wcsstr(haystack, needle); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wmemchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) 4 | { 5 | for (; n && *s != c; n--, s++); 6 | return n ? (wchar_t *)s : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wmemcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int wmemcmp(const wchar_t *l, const wchar_t *r, size_t n) 4 | { 5 | for (; n && *l==*r; n--, l++, r++); 6 | return n ? *l-*r : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wmemcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) 4 | { 5 | wchar_t *a = d; 6 | while (n--) *d++ = *s++; 7 | return a; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wmemmove.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n) 5 | { 6 | wchar_t *d0 = d; 7 | if (d == s) return d; 8 | if ((uintptr_t)d-(uintptr_t)s < n * sizeof *d) 9 | while (n--) d[n] = s[n]; 10 | else 11 | while (n--) *d++ = *s++; 12 | return d0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/wmemset.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | wchar_t *wmemset(wchar_t *d, wchar_t c, size_t n) 4 | { 5 | wchar_t *ret = d; 6 | while (n--) *d++ = c; 7 | return ret; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/x86_64/memcpy.s: -------------------------------------------------------------------------------- 1 | .global memcpy 2 | .global __memcpy_fwd 3 | .hidden __memcpy_fwd 4 | .type memcpy,@function 5 | memcpy: 6 | __memcpy_fwd: 7 | mov %rdi,%rax 8 | cmp $8,%rdx 9 | jc 1f 10 | test $7,%edi 11 | jz 1f 12 | 2: movsb 13 | dec %rdx 14 | test $7,%edi 15 | jnz 2b 16 | 1: mov %rdx,%rcx 17 | shr $3,%rcx 18 | rep 19 | movsq 20 | and $7,%edx 21 | jz 1f 22 | 2: movsb 23 | dec %edx 24 | jnz 2b 25 | 1: ret 26 | -------------------------------------------------------------------------------- /src/libraries/musl/src/string/x86_64/memmove.s: -------------------------------------------------------------------------------- 1 | .global memmove 2 | .type memmove,@function 3 | memmove: 4 | mov %rdi,%rax 5 | sub %rsi,%rax 6 | cmp %rdx,%rax 7 | .hidden __memcpy_fwd 8 | jae __memcpy_fwd 9 | mov %rdx,%rcx 10 | lea -1(%rdi,%rdx),%rdi 11 | lea -1(%rsi,%rdx),%rsi 12 | std 13 | rep movsb 14 | cld 15 | lea 1(%rdi),%rax 16 | ret 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/__set_thread_area.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int __set_thread_area(void *p) 4 | { 5 | #ifdef SYS_set_thread_area 6 | return __syscall(SYS_set_thread_area, p); 7 | #else 8 | return -ENOSYS; 9 | #endif 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/__tls_get_addr.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | void *__tls_get_addr(tls_mod_off_t *v) 4 | { 5 | pthread_t self = __pthread_self(); 6 | return (void *)(self->dtv[v[0]] + v[1]); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/call_once.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void call_once(once_flag *flag, void (*func)(void)) 5 | { 6 | __pthread_once(flag, func); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/clone.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pthread_impl.h" 3 | 4 | int __clone(int (*func)(void *), void *stack, int flags, void *arg, ...) 5 | { 6 | return -ENOSYS; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/cnd_broadcast.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int cnd_broadcast(cnd_t *c) 5 | { 6 | /* This internal function never fails, and always returns zero, 7 | * which matches the value thrd_success is defined with. */ 8 | return __private_cond_signal((pthread_cond_t *)c, -1); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/cnd_destroy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void cnd_destroy(cnd_t *c) 4 | { 5 | /* For private cv this is a no-op */ 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/cnd_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int cnd_init(cnd_t *c) 4 | { 5 | *c = (cnd_t){ 0 }; 6 | return thrd_success; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/cnd_signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int cnd_signal(cnd_t *c) 5 | { 6 | /* This internal function never fails, and always returns zero, 7 | * which matches the value thrd_success is defined with. */ 8 | return __private_cond_signal((pthread_cond_t *)c, 1); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/cnd_wait.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int cnd_wait(cnd_t *c, mtx_t *m) 4 | { 5 | /* Calling cnd_timedwait with a null pointer is an extension. 6 | * It is convenient here to avoid duplication of the logic 7 | * for return values. */ 8 | return cnd_timedwait(c, m, 0); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/default_attr.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | unsigned __default_stacksize = DEFAULT_STACK_SIZE; 4 | unsigned __default_guardsize = DEFAULT_GUARD_SIZE; 5 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/lock_ptc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; 4 | 5 | void __inhibit_ptc() 6 | { 7 | pthread_rwlock_wrlock(&lock); 8 | } 9 | 10 | void __acquire_ptc() 11 | { 12 | pthread_rwlock_rdlock(&lock); 13 | } 14 | 15 | void __release_ptc() 16 | { 17 | pthread_rwlock_unlock(&lock); 18 | } 19 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/mtx_destroy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void mtx_destroy(mtx_t *mtx) 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/mtx_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | int mtx_init(mtx_t *m, int type) 5 | { 6 | *m = (mtx_t){ 7 | ._m_type = ((type&mtx_recursive) ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL), 8 | }; 9 | return thrd_success; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/mtx_lock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | int mtx_lock(mtx_t *m) 5 | { 6 | if (m->_m_type == PTHREAD_MUTEX_NORMAL && !a_cas(&m->_m_lock, 0, EBUSY)) 7 | return thrd_success; 8 | /* Calling mtx_timedlock with a null pointer is an extension. 9 | * It is convenient, here to avoid duplication of the logic 10 | * for return values. */ 11 | return mtx_timedlock(m, 0); 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/mtx_timedlock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts) 6 | { 7 | int ret = __pthread_mutex_timedlock((pthread_mutex_t *)m, ts); 8 | switch (ret) { 9 | default: return thrd_error; 10 | case 0: return thrd_success; 11 | case ETIMEDOUT: return thrd_timedout; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/mtx_unlock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int mtx_unlock(mtx_t *mtx) 5 | { 6 | /* The only cases where pthread_mutex_unlock can return an 7 | * error are undefined behavior for C11 mtx_unlock, so we can 8 | * assume it does not return an error and simply tail call. */ 9 | return __pthread_mutex_unlock((pthread_mutex_t *)mtx); 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_destroy(pthread_attr_t *a) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_init(pthread_attr_t *a) 4 | { 5 | *a = (pthread_attr_t){0}; 6 | __acquire_ptc(); 7 | a->_a_stacksize = __default_stacksize; 8 | a->_a_guardsize = __default_guardsize; 9 | __release_ptc(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setdetachstate.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setdetachstate(pthread_attr_t *a, int state) 4 | { 5 | if (state > 1U) return EINVAL; 6 | a->_a_detach = state; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setguardsize.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setguardsize(pthread_attr_t *a, size_t size) 4 | { 5 | if (size > SIZE_MAX/8) return EINVAL; 6 | a->_a_guardsize = size; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setinheritsched.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include "syscall.h" 3 | 4 | int pthread_attr_setinheritsched(pthread_attr_t *a, int inherit) 5 | { 6 | if (inherit > 1U) return EINVAL; 7 | a->_a_sched = inherit; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setschedparam.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param) 4 | { 5 | a->_a_prio = param->sched_priority; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setschedpolicy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setschedpolicy(pthread_attr_t *a, int policy) 4 | { 5 | a->_a_policy = policy; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setscope.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setscope(pthread_attr_t *a, int scope) 4 | { 5 | switch (scope) { 6 | case PTHREAD_SCOPE_SYSTEM: 7 | return 0; 8 | case PTHREAD_SCOPE_PROCESS: 9 | return ENOTSUP; 10 | default: 11 | return EINVAL; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setstack.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setstack(pthread_attr_t *a, void *addr, size_t size) 4 | { 5 | if (size-PTHREAD_STACK_MIN > SIZE_MAX/4) return EINVAL; 6 | a->_a_stackaddr = (size_t)addr + size; 7 | a->_a_stacksize = size; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_attr_setstacksize.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_attr_setstacksize(pthread_attr_t *a, size_t size) 4 | { 5 | if (size-PTHREAD_STACK_MIN > SIZE_MAX/4) return EINVAL; 6 | a->_a_stackaddr = 0; 7 | a->_a_stacksize = size; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_barrier_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_barrier_destroy(pthread_barrier_t *b) 4 | { 5 | if (b->_b_limit < 0) { 6 | if (b->_b_lock) { 7 | int v; 8 | a_or(&b->_b_lock, INT_MIN); 9 | while ((v = b->_b_lock) & INT_MAX) 10 | __wait(&b->_b_lock, 0, v, 0); 11 | } 12 | __vm_wait(); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_barrier_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count) 4 | { 5 | if (count-1 > INT_MAX-1) return EINVAL; 6 | *b = (pthread_barrier_t){ ._b_limit = count-1 | (a?a->__attr:0) }; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_barrierattr_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_barrierattr_destroy(pthread_barrierattr_t *a) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_barrierattr_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_barrierattr_init(pthread_barrierattr_t *a) 4 | { 5 | *a = (pthread_barrierattr_t){0}; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_barrierattr_setpshared.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared) 4 | { 5 | if (pshared > 1U) return EINVAL; 6 | a->__attr = pshared ? INT_MIN : 0; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_cond_broadcast.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_cond_broadcast(pthread_cond_t *c) 4 | { 5 | if (!c->_c_shared) return __private_cond_signal(c, -1); 6 | if (!c->_c_waiters) return 0; 7 | a_inc(&c->_c_seq); 8 | __wake(&c->_c_seq, -1, 0); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_cond_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_cond_destroy(pthread_cond_t *c) 4 | { 5 | if (c->_c_shared && c->_c_waiters) { 6 | int cnt; 7 | a_or(&c->_c_waiters, 0x80000000); 8 | a_inc(&c->_c_seq); 9 | __wake(&c->_c_seq, -1, 0); 10 | while ((cnt = c->_c_waiters) & 0x7fffffff) 11 | __wait(&c->_c_waiters, 0, cnt, 0); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_cond_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a) 4 | { 5 | *c = (pthread_cond_t){0}; 6 | if (a) { 7 | c->_c_clock = a->__attr & 0x7fffffff; 8 | if (a->__attr>>31) c->_c_shared = (void *)-1; 9 | } 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_cond_signal.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_cond_signal(pthread_cond_t *c) 4 | { 5 | if (!c->_c_shared) return __private_cond_signal(c, 1); 6 | if (!c->_c_waiters) return 0; 7 | a_inc(&c->_c_seq); 8 | __wake(&c->_c_seq, 1, 0); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_cond_wait.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m) 4 | { 5 | return pthread_cond_timedwait(c, m, 0); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_condattr_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_condattr_destroy(pthread_condattr_t *a) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_condattr_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_condattr_init(pthread_condattr_t *a) 4 | { 5 | *a = (pthread_condattr_t){0}; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_condattr_setclock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk) 4 | { 5 | if (clk < 0 || clk-2U < 2) return EINVAL; 6 | a->__attr &= 0x80000000; 7 | a->__attr |= clk; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_condattr_setpshared.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_condattr_setpshared(pthread_condattr_t *a, int pshared) 4 | { 5 | if (pshared > 1U) return EINVAL; 6 | a->__attr &= 0x7fffffff; 7 | a->__attr |= (unsigned)pshared<<31; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_equal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static int __pthread_equal(pthread_t a, pthread_t b) 5 | { 6 | return a==b; 7 | } 8 | 9 | weak_alias(__pthread_equal, pthread_equal); 10 | weak_alias(__pthread_equal, thrd_equal); 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_getconcurrency.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int pthread_getconcurrency() 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_getcpuclockid.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_getcpuclockid(pthread_t t, clockid_t *clockid) 4 | { 5 | *clockid = (-t->tid-1)*8U + 6; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_getspecific.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | static void *__pthread_getspecific(pthread_key_t k) 5 | { 6 | struct pthread *self = __pthread_self(); 7 | return self->tsd[k]; 8 | } 9 | 10 | weak_alias(__pthread_getspecific, pthread_getspecific); 11 | weak_alias(__pthread_getspecific, tss_get); 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutex_consistent.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include "atomic.h" 3 | 4 | int pthread_mutex_consistent(pthread_mutex_t *m) 5 | { 6 | int old = m->_m_lock; 7 | int own = old & 0x3fffffff; 8 | if (!(m->_m_type & 4) || !own || !(old & 0x40000000)) 9 | return EINVAL; 10 | if (own != __pthread_self()->tid) 11 | return EPERM; 12 | a_and(&m->_m_lock, ~0x40000000); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutex_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutex_destroy(pthread_mutex_t *mutex) 4 | { 5 | /* If the mutex being destroyed is process-shared and has nontrivial 6 | * type (tracking ownership), it might be in the pending slot of a 7 | * robust_list; wait for quiescence. */ 8 | if (mutex->_m_type > 128) __vm_wait(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutex_getprioceiling.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutex_getprioceiling(const pthread_mutex_t *restrict m, int *restrict ceiling) 4 | { 5 | return EINVAL; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutex_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a) 4 | { 5 | *m = (pthread_mutex_t){0}; 6 | if (a) m->_m_type = a->__attr; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutex_lock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int __pthread_mutex_lock(pthread_mutex_t *m) 4 | { 5 | if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL 6 | && !a_cas(&m->_m_lock, 0, EBUSY)) 7 | return 0; 8 | 9 | return __pthread_mutex_timedlock(m, 0); 10 | } 11 | 12 | weak_alias(__pthread_mutex_lock, pthread_mutex_lock); 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutex_setprioceiling.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutex_setprioceiling(pthread_mutex_t *restrict m, int ceiling, int *restrict old) 4 | { 5 | return EINVAL; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutexattr_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutexattr_destroy(pthread_mutexattr_t *a) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutexattr_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutexattr_init(pthread_mutexattr_t *a) 4 | { 5 | *a = (pthread_mutexattr_t){0}; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutexattr_setpshared.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutexattr_setpshared(pthread_mutexattr_t *a, int pshared) 4 | { 5 | if (pshared > 1U) return EINVAL; 6 | a->__attr &= ~128U; 7 | a->__attr |= pshared<<7; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_mutexattr_settype.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_mutexattr_settype(pthread_mutexattr_t *a, int type) 4 | { 5 | if ((unsigned)type > 2) return EINVAL; 6 | a->__attr = (a->__attr & ~3) | type; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlock_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_rwlock_destroy(pthread_rwlock_t *rw) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlock_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) 4 | { 5 | *rw = (pthread_rwlock_t){0}; 6 | if (a) rw->_rw_shared = a->__attr[0]*128; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlock_rdlock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int __pthread_rwlock_rdlock(pthread_rwlock_t *rw) 4 | { 5 | return __pthread_rwlock_timedrdlock(rw, 0); 6 | } 7 | 8 | weak_alias(__pthread_rwlock_rdlock, pthread_rwlock_rdlock); 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlock_trywrlock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int __pthread_rwlock_trywrlock(pthread_rwlock_t *rw) 4 | { 5 | if (a_cas(&rw->_rw_lock, 0, 0x7fffffff)) return EBUSY; 6 | return 0; 7 | } 8 | 9 | weak_alias(__pthread_rwlock_trywrlock, pthread_rwlock_trywrlock); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlock_wrlock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int __pthread_rwlock_wrlock(pthread_rwlock_t *rw) 4 | { 5 | return __pthread_rwlock_timedwrlock(rw, 0); 6 | } 7 | 8 | weak_alias(__pthread_rwlock_wrlock, pthread_rwlock_wrlock); 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlockattr_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_rwlockattr_destroy(pthread_rwlockattr_t *a) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlockattr_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_rwlockattr_init(pthread_rwlockattr_t *a) 4 | { 5 | *a = (pthread_rwlockattr_t){0}; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_rwlockattr_setpshared.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int pshared) 4 | { 5 | if (pshared > 1U) return EINVAL; 6 | a->__attr[0] = pshared; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_self.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | static pthread_t __pthread_self_internal() 5 | { 6 | return __pthread_self(); 7 | } 8 | 9 | weak_alias(__pthread_self_internal, pthread_self); 10 | weak_alias(__pthread_self_internal, thrd_current); 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_setcancelstate.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int __pthread_setcancelstate(int new, int *old) 4 | { 5 | if (new > 2U) return EINVAL; 6 | struct pthread *self = __pthread_self(); 7 | if (old) *old = self->canceldisable; 8 | self->canceldisable = new; 9 | return 0; 10 | } 11 | 12 | weak_alias(__pthread_setcancelstate, pthread_setcancelstate); 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_setcanceltype.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_setcanceltype(int new, int *old) 4 | { 5 | struct pthread *self = __pthread_self(); 6 | if (new > 1U) return EINVAL; 7 | if (old) *old = self->cancelasync; 8 | self->cancelasync = new; 9 | if (new) pthread_testcancel(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_setconcurrency.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int pthread_setconcurrency(int val) 5 | { 6 | if (val < 0) return EINVAL; 7 | if (val > 0) return EAGAIN; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_setschedparam.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include "lock.h" 3 | 4 | int pthread_setschedparam(pthread_t t, int policy, const struct sched_param *param) 5 | { 6 | int r; 7 | sigset_t set; 8 | __block_app_sigs(&set); 9 | LOCK(t->killlock); 10 | r = !t->tid ? ESRCH : -__syscall(SYS_sched_setscheduler, t->tid, policy, param); 11 | UNLOCK(t->killlock); 12 | __restore_sigs(&set); 13 | return r; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_setschedprio.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include "lock.h" 3 | 4 | int pthread_setschedprio(pthread_t t, int prio) 5 | { 6 | int r; 7 | sigset_t set; 8 | __block_app_sigs(&set); 9 | LOCK(t->killlock); 10 | r = !t->tid ? ESRCH : -__syscall(SYS_sched_setparam, t->tid, &prio); 11 | UNLOCK(t->killlock); 12 | __restore_sigs(&set); 13 | return r; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_setspecific.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_setspecific(pthread_key_t k, const void *x) 4 | { 5 | struct pthread *self = __pthread_self(); 6 | /* Avoid unnecessary COW */ 7 | if (self->tsd[k] != x) { 8 | self->tsd[k] = (void *)x; 9 | self->tsd_used = 1; 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_spin_destroy.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_spin_destroy(pthread_spinlock_t *s) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_spin_init.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_spin_init(pthread_spinlock_t *s, int shared) 4 | { 5 | return *s = 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_spin_lock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | int pthread_spin_lock(pthread_spinlock_t *s) 5 | { 6 | while (*(volatile int *)s || a_cas(s, 0, EBUSY)) a_spin(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_spin_trylock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | int pthread_spin_trylock(pthread_spinlock_t *s) 5 | { 6 | return a_cas(s, 0, EBUSY); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_spin_unlock.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | int pthread_spin_unlock(pthread_spinlock_t *s) 4 | { 5 | a_store(s, 0); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/pthread_testcancel.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | 3 | static void dummy() 4 | { 5 | } 6 | 7 | weak_alias(dummy, __testcancel); 8 | 9 | void __pthread_testcancel() 10 | { 11 | __testcancel(); 12 | } 13 | 14 | weak_alias(__pthread_testcancel, pthread_testcancel); 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/sem_destroy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sem_destroy(sem_t *sem) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/sem_getvalue.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sem_getvalue(sem_t *restrict sem, int *restrict valp) 4 | { 5 | int val = sem->__val[0]; 6 | *valp = val < 0 ? 0 : val; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/sem_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int sem_init(sem_t *sem, int pshared, unsigned value) 6 | { 7 | if (value > SEM_VALUE_MAX) { 8 | errno = EINVAL; 9 | return -1; 10 | } 11 | sem->__val[0] = value; 12 | sem->__val[1] = 0; 13 | sem->__val[2] = pshared ? 0 : 128; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/sem_trywait.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pthread_impl.h" 3 | 4 | int sem_trywait(sem_t *sem) 5 | { 6 | int val; 7 | while ((val=sem->__val[0]) > 0) { 8 | int new = val-1-(val==1 && sem->__val[1]); 9 | if (a_cas(sem->__val, val, new)==val) return 0; 10 | } 11 | errno = EAGAIN; 12 | return -1; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/sem_unlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sem_unlink(const char *name) 5 | { 6 | return shm_unlink(name); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/sem_wait.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sem_wait(sem_t *sem) 4 | { 5 | return sem_timedwait(sem, 0); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/syscall_cp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/src/thread/syscall_cp.c -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/thrd_create.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) 5 | { 6 | int ret = __pthread_create(thr, __ATTRP_C11_THREAD, (void *(*)(void *))func, arg); 7 | switch (ret) { 8 | case 0: return thrd_success; 9 | case EAGAIN: return thrd_nomem; 10 | default: return thrd_error; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/thrd_exit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | _Noreturn void thrd_exit(int result) 6 | { 7 | __pthread_exit((void*)(intptr_t)result); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/thrd_join.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int thrd_join(thrd_t t, int *res) 6 | { 7 | void *pthread_res; 8 | __pthread_join(t, &pthread_res); 9 | if (res) *res = (int)(intptr_t)pthread_res; 10 | return thrd_success; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/thrd_sleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "syscall.h" 5 | 6 | int thrd_sleep(const struct timespec *req, struct timespec *rem) 7 | { 8 | int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem); 9 | switch (ret) { 10 | case 0: return 0; 11 | case -EINTR: return -1; /* value specified by C11 */ 12 | default: return -2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/thrd_yield.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | void thrd_yield() 5 | { 6 | __syscall(SYS_sched_yield); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/tls.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nothotscott/VisualOS/1d51f9721feffa303b7ac8fd8ac5520ee5ee3732/src/libraries/musl/src/thread/tls.c -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/tss_create.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int tss_create(tss_t *tss, tss_dtor_t dtor) 5 | { 6 | /* Different error returns are possible. C glues them together into 7 | * just failure notification. Can't be optimized to a tail call, 8 | * unless thrd_error equals EAGAIN. */ 9 | return __pthread_key_create(tss, dtor) ? thrd_error : thrd_success; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/tss_delete.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void tss_delete(tss_t key) 5 | { 6 | __pthread_key_delete(key); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/tss_set.c: -------------------------------------------------------------------------------- 1 | #include "pthread_impl.h" 2 | #include 3 | 4 | int tss_set(tss_t k, void *x) 5 | { 6 | struct pthread *self = __pthread_self(); 7 | /* Avoid unnecessary COW */ 8 | if (self->tsd[k] != x) { 9 | self->tsd[k] = x; 10 | self->tsd_used = 1; 11 | } 12 | return thrd_success; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/thread/x86_64/__unmapself.s: -------------------------------------------------------------------------------- 1 | /* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ 2 | .text 3 | .global __unmapself 4 | .type __unmapself,@function 5 | __unmapself: 6 | movl $11,%eax /* SYS_munmap */ 7 | syscall /* munmap(arg2,arg3) */ 8 | xor %rdi,%rdi /* exit() args: always return success */ 9 | movl $60,%eax /* SYS_exit */ 10 | syscall /* exit(0) */ 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/__month_to_secs.c: -------------------------------------------------------------------------------- 1 | int __month_to_secs(int month, int is_leap) 2 | { 3 | static const int secs_through_month[] = { 4 | 0, 31*86400, 59*86400, 90*86400, 5 | 120*86400, 151*86400, 181*86400, 212*86400, 6 | 243*86400, 273*86400, 304*86400, 334*86400 }; 7 | int t = secs_through_month[month]; 8 | if (is_leap && month >= 2) t+=86400; 9 | return t; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/asctime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *asctime(const struct tm *tm) 4 | { 5 | static char buf[26]; 6 | return __asctime_r(tm, buf); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/clock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | clock_t clock() 5 | { 6 | struct timespec ts; 7 | 8 | if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts)) 9 | return -1; 10 | 11 | if (ts.tv_sec > LONG_MAX/1000000 12 | || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec) 13 | return -1; 14 | 15 | return ts.tv_sec*1000000 + ts.tv_nsec/1000; 16 | } 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/clock_getcpuclockid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "syscall.h" 5 | 6 | int clock_getcpuclockid(pid_t pid, clockid_t *clk) 7 | { 8 | struct timespec ts; 9 | clockid_t id = (-pid-1)*8U + 2; 10 | int ret = __syscall(SYS_clock_getres, id, &ts); 11 | if (ret) return -ret; 12 | *clk = id; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/ctime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *ctime(const time_t *t) 4 | { 5 | struct tm *tm = localtime(t); 6 | if (!tm) return 0; 7 | return asctime(tm); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/ctime_r.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *ctime_r(const time_t *t, char *buf) 4 | { 5 | struct tm tm, *tm_p = localtime_r(t, &tm); 6 | return tm_p ? asctime_r(tm_p, buf) : 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/difftime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double difftime(time_t t1, time_t t0) 4 | { 5 | return t1-t0; 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/ftime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int ftime(struct timeb *tp) 5 | { 6 | struct timespec ts; 7 | clock_gettime(CLOCK_REALTIME, &ts); 8 | tp->time = ts.tv_sec; 9 | tp->millitm = ts.tv_nsec / 1000000; 10 | tp->timezone = tp->dstflag = 0; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int gettimeofday(struct timeval *restrict tv, void *restrict tz) 6 | { 7 | struct timespec ts; 8 | if (!tv) return 0; 9 | clock_gettime(CLOCK_REALTIME, &ts); 10 | tv->tv_sec = ts.tv_sec; 11 | tv->tv_usec = (int)ts.tv_nsec / 1000; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/gmtime.c: -------------------------------------------------------------------------------- 1 | #include "time_impl.h" 2 | #include 3 | 4 | struct tm *gmtime(const time_t *t) 5 | { 6 | static struct tm tm; 7 | return __gmtime_r(t, &tm); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/gmtime_r.c: -------------------------------------------------------------------------------- 1 | #include "time_impl.h" 2 | #include 3 | 4 | struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm) 5 | { 6 | if (__secs_to_tm(*t, tm) < 0) { 7 | errno = EOVERFLOW; 8 | return 0; 9 | } 10 | tm->tm_isdst = 0; 11 | tm->__tm_gmtoff = 0; 12 | tm->__tm_zone = __utc; 13 | return tm; 14 | } 15 | 16 | weak_alias(__gmtime_r, gmtime_r); 17 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/localtime.c: -------------------------------------------------------------------------------- 1 | #include "time_impl.h" 2 | 3 | struct tm *localtime(const time_t *t) 4 | { 5 | static struct tm tm; 6 | return __localtime_r(t, &tm); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/nanosleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int nanosleep(const struct timespec *req, struct timespec *rem) 5 | { 6 | return __syscall_ret(-__clock_nanosleep(CLOCK_REALTIME, 0, req, rem)); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/time.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | time_t time(time_t *t) 5 | { 6 | struct timespec ts; 7 | __clock_gettime(CLOCK_REALTIME, &ts); 8 | if (t) *t = ts.tv_sec; 9 | return ts.tv_sec; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/timegm.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include "time_impl.h" 3 | #include 4 | 5 | time_t timegm(struct tm *tm) 6 | { 7 | struct tm new; 8 | long long t = __tm_to_secs(tm); 9 | if (__secs_to_tm(t, &new) < 0) { 10 | errno = EOVERFLOW; 11 | return -1; 12 | } 13 | *tm = new; 14 | tm->tm_isdst = 0; 15 | tm->__tm_gmtoff = 0; 16 | tm->__tm_zone = __utc; 17 | return t; 18 | } 19 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/timer_delete.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "pthread_impl.h" 4 | 5 | int timer_delete(timer_t t) 6 | { 7 | if ((intptr_t)t < 0) { 8 | pthread_t td = (void *)((uintptr_t)t << 1); 9 | a_store(&td->timer_id, td->timer_id | INT_MIN); 10 | __syscall(SYS_tkill, td->tid, SIGTIMER); 11 | return 0; 12 | } 13 | return __syscall(SYS_timer_delete, t); 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/timer_getoverrun.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "pthread_impl.h" 4 | 5 | int timer_getoverrun(timer_t t) 6 | { 7 | if ((intptr_t)t < 0) { 8 | pthread_t td = (void *)((uintptr_t)t << 1); 9 | t = (void *)(uintptr_t)(td->timer_id & INT_MAX); 10 | } 11 | return syscall(SYS_timer_getoverrun, t); 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/times.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | clock_t times(struct tms *tms) 5 | { 6 | return __syscall(SYS_times, tms); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/timespec_get.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* There is no other implemented value than TIME_UTC; all other values 4 | * are considered erroneous. */ 5 | int timespec_get(struct timespec * ts, int base) 6 | { 7 | if (base != TIME_UTC) return 0; 8 | int ret = __clock_gettime(CLOCK_REALTIME, ts); 9 | return ret < 0 ? 0 : base; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/time/utime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int utime(const char *path, const struct utimbuf *times) 7 | { 8 | return utimensat(AT_FDCWD, path, times ? ((struct timespec [2]){ 9 | { .tv_sec = times->actime }, { .tv_sec = times->modtime }}) 10 | : 0, 0); 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/_exit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | _Noreturn void _exit(int status) 5 | { 6 | _Exit(status); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/access.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int access(const char *filename, int amode) 6 | { 7 | #ifdef SYS_access 8 | return syscall(SYS_access, filename, amode); 9 | #else 10 | return syscall(SYS_faccessat, AT_FDCWD, filename, amode, 0); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/acct.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "syscall.h" 4 | 5 | int acct(const char *filename) 6 | { 7 | return syscall(SYS_acct, filename); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/alarm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | unsigned alarm(unsigned seconds) 6 | { 7 | struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 }; 8 | setitimer(ITIMER_REAL, &it, &old); 9 | return old.it_value.tv_sec + !!old.it_value.tv_usec; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/chdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int chdir(const char *path) 5 | { 6 | return syscall(SYS_chdir, path); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/chown.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int chown(const char *path, uid_t uid, gid_t gid) 6 | { 7 | #ifdef SYS_chown 8 | return syscall(SYS_chown, path, uid, gid); 9 | #else 10 | return syscall(SYS_fchownat, AT_FDCWD, path, uid, gid, 0); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/close.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "aio_impl.h" 4 | #include "syscall.h" 5 | 6 | static int dummy(int fd) 7 | { 8 | return fd; 9 | } 10 | 11 | weak_alias(dummy, __aio_close); 12 | 13 | int close(int fd) 14 | { 15 | fd = __aio_close(fd); 16 | int r = __syscall_cp(SYS_close, fd); 17 | if (r == -EINTR) r = 0; 18 | return __syscall_ret(r); 19 | } 20 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/ctermid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *ctermid(char *s) 5 | { 6 | return s ? strcpy(s, "/dev/tty") : "/dev/tty"; 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/dup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int dup(int fd) 5 | { 6 | return syscall(SYS_dup, fd); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/fchdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "syscall.h" 5 | 6 | int fchdir(int fd) 7 | { 8 | int ret = __syscall(SYS_fchdir, fd); 9 | if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0) 10 | return __syscall_ret(ret); 11 | 12 | char buf[15+3*sizeof(int)]; 13 | __procfdname(buf, fd); 14 | return syscall(SYS_chdir, buf); 15 | } 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/fchownat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag) 5 | { 6 | return syscall(SYS_fchownat, fd, path, uid, gid, flag); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/fdatasync.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int fdatasync(int fd) 5 | { 6 | return syscall_cp(SYS_fdatasync, fd); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/fsync.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int fsync(int fd) 5 | { 6 | return syscall_cp(SYS_fsync, fd); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/ftruncate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int ftruncate(int fd, off_t length) 5 | { 6 | return syscall(SYS_ftruncate, fd, __SYSCALL_LL_O(length)); 7 | } 8 | 9 | weak_alias(ftruncate, ftruncate64); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getegid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | gid_t getegid(void) 5 | { 6 | return __syscall(SYS_getegid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/geteuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | uid_t geteuid(void) 5 | { 6 | return __syscall(SYS_geteuid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getgid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | gid_t getgid(void) 5 | { 6 | return __syscall(SYS_getgid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getgroups.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int getgroups(int count, gid_t list[]) 5 | { 6 | return syscall(SYS_getgroups, count, list); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/gethostname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int gethostname(char *name, size_t len) 5 | { 6 | size_t i; 7 | struct utsname uts; 8 | if (uname(&uts)) return -1; 9 | if (len > sizeof uts.nodename) len = sizeof uts.nodename; 10 | for (i=0; i 2 | #include 3 | 4 | char *getlogin(void) 5 | { 6 | return getenv("LOGNAME"); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getlogin_r.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int getlogin_r(char *name, size_t size) 6 | { 7 | char *logname = getlogin(); 8 | if (!logname) return ENXIO; /* or...? */ 9 | if (strlen(logname) >= size) return ERANGE; 10 | strcpy(name, logname); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getpgid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | pid_t getpgid(pid_t pid) 5 | { 6 | return syscall(SYS_getpgid, pid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getpgrp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | pid_t getpgrp(void) 5 | { 6 | return __syscall(SYS_getpgid, 0); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getpid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | pid_t getpid(void) 5 | { 6 | return __syscall(SYS_getpid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getppid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | pid_t getppid(void) 5 | { 6 | return __syscall(SYS_getppid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getsid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | pid_t getsid(pid_t pid) 5 | { 6 | return syscall(SYS_getsid, pid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/getuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | uid_t getuid(void) 5 | { 6 | return __syscall(SYS_getuid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/isatty.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "syscall.h" 5 | 6 | int isatty(int fd) 7 | { 8 | struct winsize wsz; 9 | unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz); 10 | if (r == 0) return 1; 11 | if (errno != EBADF) errno = ENOTTY; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/lchown.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int lchown(const char *path, uid_t uid, gid_t gid) 6 | { 7 | #ifdef SYS_lchown 8 | return syscall(SYS_lchown, path, uid, gid); 9 | #else 10 | return syscall(SYS_fchownat, AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/link.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int link(const char *existing, const char *new) 6 | { 7 | #ifdef SYS_link 8 | return syscall(SYS_link, existing, new); 9 | #else 10 | return syscall(SYS_linkat, AT_FDCWD, existing, AT_FDCWD, new, 0); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/linkat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int linkat(int fd1, const char *existing, int fd2, const char *new, int flag) 5 | { 6 | return syscall(SYS_linkat, fd1, existing, fd2, new, flag); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/lseek.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | off_t __lseek(int fd, off_t offset, int whence) 5 | { 6 | #ifdef SYS__llseek 7 | off_t result; 8 | return syscall(SYS__llseek, fd, offset>>32, offset, &result, whence) ? -1 : result; 9 | #else 10 | return syscall(SYS_lseek, fd, offset, whence); 11 | #endif 12 | } 13 | 14 | weak_alias(__lseek, lseek); 15 | weak_alias(__lseek, lseek64); 16 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/pause.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int pause(void) 5 | { 6 | #ifdef SYS_pause 7 | return syscall_cp(SYS_pause); 8 | #else 9 | return syscall_cp(SYS_ppoll, 0, 0, 0, 0); 10 | #endif 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/pipe.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int pipe(int fd[2]) 5 | { 6 | #ifdef SYS_pipe 7 | return syscall(SYS_pipe, fd); 8 | #else 9 | return syscall(SYS_pipe2, fd, 0); 10 | #endif 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/posix_close.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int posix_close(int fd, int flags) 4 | { 5 | return close(fd); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/pread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t pread(int fd, void *buf, size_t size, off_t ofs) 5 | { 6 | return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs)); 7 | } 8 | 9 | weak_alias(pread, pread64); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/preadv.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | #include "syscall.h" 5 | 6 | ssize_t preadv(int fd, const struct iovec *iov, int count, off_t ofs) 7 | { 8 | return syscall_cp(SYS_preadv, fd, iov, count, 9 | (long)(ofs), (long)(ofs>>32)); 10 | } 11 | 12 | weak_alias(preadv, preadv64); 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/pwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs) 5 | { 6 | return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs)); 7 | } 8 | 9 | weak_alias(pwrite, pwrite64); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/pwritev.c: -------------------------------------------------------------------------------- 1 | #define _BSD_SOURCE 2 | #include 3 | #include 4 | #include "syscall.h" 5 | 6 | ssize_t pwritev(int fd, const struct iovec *iov, int count, off_t ofs) 7 | { 8 | return syscall_cp(SYS_pwritev, fd, iov, count, 9 | (long)(ofs), (long)(ofs>>32)); 10 | } 11 | 12 | weak_alias(pwritev, pwritev64); 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/read.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t read(int fd, void *buf, size_t count) 5 | { 6 | return syscall_cp(SYS_read, fd, buf, count); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/readlinkat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize) 5 | { 6 | char dummy[1]; 7 | if (!bufsize) { 8 | buf = dummy; 9 | bufsize = 1; 10 | } 11 | int r = __syscall(SYS_readlinkat, fd, path, buf, bufsize); 12 | if (buf == dummy && r > 0) r = 0; 13 | return __syscall_ret(r); 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/readv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t readv(int fd, const struct iovec *iov, int count) 5 | { 6 | return syscall_cp(SYS_readv, fd, iov, count); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/renameat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int renameat(int oldfd, const char *old, int newfd, const char *new) 5 | { 6 | #ifdef SYS_renameat 7 | return syscall(SYS_renameat, oldfd, old, newfd, new); 8 | #else 9 | return syscall(SYS_renameat2, oldfd, old, newfd, new, 0); 10 | #endif 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/rmdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int rmdir(const char *path) 6 | { 7 | #ifdef SYS_rmdir 8 | return syscall(SYS_rmdir, path); 9 | #else 10 | return syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setegid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libc.h" 3 | #include "syscall.h" 4 | 5 | int setegid(gid_t egid) 6 | { 7 | return __setxid(SYS_setresgid, -1, egid, -1); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/seteuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | #include "libc.h" 4 | 5 | int seteuid(uid_t euid) 6 | { 7 | return __setxid(SYS_setresuid, -1, euid, -1); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setgid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | #include "libc.h" 4 | 5 | int setgid(gid_t gid) 6 | { 7 | return __setxid(SYS_setgid, gid, 0, 0); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setpgid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int setpgid(pid_t pid, pid_t pgid) 5 | { 6 | return syscall(SYS_setpgid, pid, pgid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setpgrp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | pid_t setpgrp(void) 4 | { 5 | return setpgid(0, 0); 6 | } 7 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setregid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | #include "libc.h" 4 | 5 | int setregid(gid_t rgid, gid_t egid) 6 | { 7 | return __setxid(SYS_setregid, rgid, egid, 0); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setresgid.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "syscall.h" 4 | #include "libc.h" 5 | 6 | int setresgid(gid_t rgid, gid_t egid, gid_t sgid) 7 | { 8 | return __setxid(SYS_setresgid, rgid, egid, sgid); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setresuid.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include "syscall.h" 4 | #include "libc.h" 5 | 6 | int setresuid(uid_t ruid, uid_t euid, uid_t suid) 7 | { 8 | return __setxid(SYS_setresuid, ruid, euid, suid); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setreuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | #include "libc.h" 4 | 5 | int setreuid(uid_t ruid, uid_t euid) 6 | { 7 | return __setxid(SYS_setreuid, ruid, euid, 0); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setsid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | pid_t setsid(void) 5 | { 6 | return syscall(SYS_setsid); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/setuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | #include "libc.h" 4 | 5 | int setuid(uid_t uid) 6 | { 7 | return __setxid(SYS_setuid, uid, 0, 0); 8 | } 9 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/sleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | unsigned sleep(unsigned seconds) 5 | { 6 | struct timespec tv = { .tv_sec = seconds, .tv_nsec = 0 }; 7 | if (nanosleep(&tv, &tv)) 8 | return tv.tv_sec; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/symlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int symlink(const char *existing, const char *new) 6 | { 7 | #ifdef SYS_symlink 8 | return syscall(SYS_symlink, existing, new); 9 | #else 10 | return syscall(SYS_symlinkat, existing, AT_FDCWD, new); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/symlinkat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int symlinkat(const char *existing, int fd, const char *new) 5 | { 6 | return syscall(SYS_symlinkat, existing, fd, new); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/sync.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | void sync(void) 5 | { 6 | __syscall(SYS_sync); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/tcgetpgrp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | pid_t tcgetpgrp(int fd) 6 | { 7 | int pgrp; 8 | if (ioctl(fd, TIOCGPGRP, &pgrp) < 0) 9 | return -1; 10 | return pgrp; 11 | } 12 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/tcsetpgrp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int tcsetpgrp(int fd, pid_t pgrp) 6 | { 7 | int pgrp_int = pgrp; 8 | return ioctl(fd, TIOCSPGRP, &pgrp_int); 9 | } 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/truncate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int truncate(const char *path, off_t length) 5 | { 6 | return syscall(SYS_truncate, path, __SYSCALL_LL_O(length)); 7 | } 8 | 9 | weak_alias(truncate, truncate64); 10 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/ttyname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *ttyname(int fd) 6 | { 7 | static char buf[TTY_NAME_MAX]; 8 | int result; 9 | if ((result = ttyname_r(fd, buf, sizeof buf))) { 10 | errno = result; 11 | return NULL; 12 | } 13 | return buf; 14 | } 15 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/ualarm.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | unsigned ualarm(unsigned value, unsigned interval) 6 | { 7 | struct itimerval it = { 8 | .it_interval.tv_usec = interval, 9 | .it_value.tv_usec = value 10 | }, it_old; 11 | setitimer(ITIMER_REAL, &it, &it_old); 12 | return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec; 13 | } 14 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/unlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "syscall.h" 4 | 5 | int unlink(const char *path) 6 | { 7 | #ifdef SYS_unlink 8 | return syscall(SYS_unlink, path); 9 | #else 10 | return syscall(SYS_unlinkat, AT_FDCWD, path, 0); 11 | #endif 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/unlinkat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | int unlinkat(int fd, const char *path, int flag) 5 | { 6 | return syscall(SYS_unlinkat, fd, path, flag); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/usleep.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | 5 | int usleep(unsigned useconds) 6 | { 7 | struct timespec tv = { 8 | .tv_sec = useconds/1000000, 9 | .tv_nsec = (useconds%1000000)*1000 10 | }; 11 | return nanosleep(&tv, &tv); 12 | } 13 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/write.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t write(int fd, const void *buf, size_t count) 5 | { 6 | return syscall_cp(SYS_write, fd, buf, count); 7 | } 8 | -------------------------------------------------------------------------------- /src/libraries/musl/src/unistd/writev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "syscall.h" 3 | 4 | ssize_t writev(int fd, const struct iovec *iov, int count) 5 | { 6 | return syscall_cp(SYS_writev, fd, iov, count); 7 | } 8 | -------------------------------------------------------------------------------- /src/limine.cfg: -------------------------------------------------------------------------------- 1 | TIMEOUT=0 2 | 3 | :VisualOS 4 | PROTOCOL=stivale2 5 | KASLR=no 6 | 7 | KERNEL_PATH=boot:///boot/vos.elf 8 | 9 | MODULE_PATH=boot:///modules/extras/zap-ext-light18.psf 10 | MODULE_STRING=font 11 | 12 | MODULE_PATH=boot:///modules/extras/VisualOS.tga 13 | MODULE_STRING=image 14 | 15 | MODULE_PATH=boot:///modules/applications/hello_world.elf 16 | MODULE_STRING=hello_world -------------------------------------------------------------------------------- /src/modules/README.md: -------------------------------------------------------------------------------- 1 | This is currently a stub 2 | 3 | TODO each directory in applications and drivers will generate an elf file that will be added to the img file --------------------------------------------------------------------------------