Skip to content

Commit 2308c7f

Browse files
[libc] Enable most of the libc entrypoitns for riscv (#99771)
This patch enables most of the libc entrypoints for riscv, except for fstatvfs, statvfs, dmull and fmull which are currently failing compilation. float16 is also not added, as rv32 doesn't seem to support it yet. This patch also fixes the call to seek, which should take an off_t, and was missed in PR #68269.
1 parent 18f7ee5 commit 2308c7f

File tree

5 files changed

+102
-16
lines changed

5 files changed

+102
-16
lines changed

libc/config/linux/riscv/entrypoints.txt

Lines changed: 97 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ set(TARGET_LIBC_ENTRYPOINTS
1717
libc.src.ctype.tolower
1818
libc.src.ctype.toupper
1919

20+
# dlfcn.h entrypoints
21+
libc.src.dlfcn.dlclose
22+
libc.src.dlfcn.dlerror
23+
libc.src.dlfcn.dlopen
24+
libc.src.dlfcn.dlsym
25+
2026
# errno.h entrypoints
2127
libc.src.errno.errno
2228

@@ -52,6 +58,7 @@ set(TARGET_LIBC_ENTRYPOINTS
5258
libc.src.string.mempcpy
5359
libc.src.string.memrchr
5460
libc.src.string.memset
61+
libc.src.string.memset_explicit
5562
libc.src.string.rindex
5663
libc.src.string.stpcpy
5764
libc.src.string.stpncpy
@@ -180,6 +187,9 @@ set(TARGET_LIBC_ENTRYPOINTS
180187
libc.src.stdlib.qsort_r
181188
libc.src.stdlib.rand
182189
libc.src.stdlib.srand
190+
libc.src.stdlib.strfromd
191+
libc.src.stdlib.strfromf
192+
libc.src.stdlib.strfroml
183193
libc.src.stdlib.strtod
184194
libc.src.stdlib.strtof
185195
libc.src.stdlib.strtol
@@ -197,6 +207,7 @@ set(TARGET_LIBC_ENTRYPOINTS
197207

198208
# stdio.h entrypoints
199209
libc.src.stdio.fdopen
210+
libc.src.stdio.fileno
200211
libc.src.stdio.fprintf
201212
libc.src.stdio.fscanf
202213
libc.src.stdio.printf
@@ -211,6 +222,14 @@ set(TARGET_LIBC_ENTRYPOINTS
211222
libc.src.stdio.vsnprintf
212223
libc.src.stdio.vsprintf
213224

225+
# sys/epoll.h entrypoints
226+
libc.src.sys.epoll.epoll_create
227+
libc.src.sys.epoll.epoll_create1
228+
libc.src.sys.epoll.epoll_ctl
229+
libc.src.sys.epoll.epoll_pwait
230+
libc.src.sys.epoll.epoll_wait
231+
libc.src.sys.epoll.epoll_pwait2
232+
214233
# sys/mman.h entrypoints
215234
libc.src.sys.mman.madvise
216235
libc.src.sys.mman.mincore
@@ -261,12 +280,6 @@ set(TARGET_LIBC_ENTRYPOINTS
261280
# sys/auxv.h entrypoints
262281
libc.src.sys.auxv.getauxval
263282

264-
# sys/epoll.h entrypoints
265-
# Disabled due to epoll_wait syscalls not being available on this platform.
266-
# libc.src.sys.epoll.epoll_wait
267-
# libc.src.sys.epoll.epoll_pwait
268-
# libc.src.sys.epoll.epoll_pwait2
269-
270283
# termios.h entrypoints
271284
libc.src.termios.cfgetispeed
272285
libc.src.termios.cfgetospeed
@@ -303,6 +316,7 @@ set(TARGET_LIBC_ENTRYPOINTS
303316
libc.src.unistd.linkat
304317
libc.src.unistd.lseek
305318
libc.src.unistd.pathconf
319+
libc.src.unistd.pipe
306320
libc.src.unistd.pread
307321
libc.src.unistd.pwrite
308322
libc.src.unistd.read
@@ -348,6 +362,9 @@ set(TARGET_LIBM_ENTRYPOINTS
348362
libc.src.math.atan2f
349363
libc.src.math.atanf
350364
libc.src.math.atanhf
365+
libc.src.math.canonicalize
366+
libc.src.math.canonicalizef
367+
libc.src.math.canonicalizel
351368
libc.src.math.cbrt
352369
libc.src.math.cbrtf
353370
libc.src.math.ceil
@@ -366,6 +383,7 @@ set(TARGET_LIBM_ENTRYPOINTS
366383
libc.src.math.exp10f
367384
libc.src.math.exp2
368385
libc.src.math.exp2f
386+
libc.src.math.exp2m1f
369387
libc.src.math.expf
370388
libc.src.math.expm1
371389
libc.src.math.expm1f
@@ -493,6 +511,9 @@ set(TARGET_LIBM_ENTRYPOINTS
493511
libc.src.math.rintf
494512
libc.src.math.rintl
495513
libc.src.math.round
514+
libc.src.math.roundeven
515+
libc.src.math.roundevenf
516+
libc.src.math.roundevenl
496517
libc.src.math.roundf
497518
libc.src.math.roundl
498519
libc.src.math.scalbn
@@ -524,8 +545,10 @@ set(TARGET_LIBM_ENTRYPOINTS
524545
if(LIBC_TYPES_HAS_FLOAT128)
525546
list(APPEND TARGET_LIBM_ENTRYPOINTS
526547
# math.h C23 _Float128 entrypoints
548+
libc.src.math.canonicalizef128
527549
libc.src.math.ceilf128
528550
libc.src.math.copysignf128
551+
libc.src.math.dmulf128
529552
libc.src.math.fabsf128
530553
libc.src.math.fdimf128
531554
libc.src.math.floorf128
@@ -540,6 +563,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
540563
libc.src.math.fminimum_numf128
541564
libc.src.math.fminimumf128
542565
libc.src.math.fmodf128
566+
libc.src.math.fmulf128
543567
libc.src.math.frexpf128
544568
libc.src.math.fromfpf128
545569
libc.src.math.fromfpxf128
@@ -557,7 +581,9 @@ if(LIBC_TYPES_HAS_FLOAT128)
557581
libc.src.math.nextafterf128
558582
libc.src.math.nextdownf128
559583
libc.src.math.nextupf128
584+
libc.src.math.remquof128
560585
libc.src.math.rintf128
586+
libc.src.math.roundevenf128
561587
libc.src.math.roundf128
562588
libc.src.math.scalbnf128
563589
libc.src.math.sqrtf128
@@ -567,14 +593,47 @@ if(LIBC_TYPES_HAS_FLOAT128)
567593
)
568594
endif()
569595

596+
if(LIBC_COMPILER_HAS_FIXED_POINT)
597+
list(APPEND TARGET_LIBM_ENTRYPOINTS
598+
# stdfix.h _Fract and _Accum entrypoints
599+
libc.src.stdfix.abshk
600+
libc.src.stdfix.abshr
601+
libc.src.stdfix.absk
602+
libc.src.stdfix.abslk
603+
libc.src.stdfix.abslr
604+
libc.src.stdfix.absr
605+
libc.src.stdfix.exphk
606+
libc.src.stdfix.expk
607+
libc.src.stdfix.roundhk
608+
libc.src.stdfix.roundhr
609+
libc.src.stdfix.roundk
610+
libc.src.stdfix.roundlk
611+
libc.src.stdfix.roundlr
612+
libc.src.stdfix.roundr
613+
libc.src.stdfix.rounduhk
614+
libc.src.stdfix.rounduhr
615+
libc.src.stdfix.rounduk
616+
libc.src.stdfix.roundulk
617+
libc.src.stdfix.roundulr
618+
libc.src.stdfix.roundur
619+
libc.src.stdfix.sqrtuhk
620+
libc.src.stdfix.sqrtuhr
621+
libc.src.stdfix.sqrtuk
622+
libc.src.stdfix.sqrtur
623+
libc.src.stdfix.sqrtulr
624+
libc.src.stdfix.uhksqrtus
625+
libc.src.stdfix.uksqrtui
626+
)
627+
endif()
628+
570629
if(LLVM_LIBC_FULL_BUILD)
571630
list(APPEND TARGET_LIBC_ENTRYPOINTS
572-
# compiler entrypoints (no corresponding header)
573-
libc.src.compiler.__stack_chk_fail
574-
575631
# assert.h entrypoints
576632
libc.src.assert.__assert_fail
577633

634+
# compiler entrypoints (no corresponding header)
635+
libc.src.compiler.__stack_chk_fail
636+
578637
# dirent.h entrypoints
579638
libc.src.dirent.closedir
580639
libc.src.dirent.dirfd
@@ -599,6 +658,12 @@ if(LLVM_LIBC_FULL_BUILD)
599658
libc.src.pthread.pthread_attr_setguardsize
600659
libc.src.pthread.pthread_attr_setstack
601660
libc.src.pthread.pthread_attr_setstacksize
661+
libc.src.pthread.pthread_condattr_destroy
662+
libc.src.pthread.pthread_condattr_getclock
663+
libc.src.pthread.pthread_condattr_getpshared
664+
libc.src.pthread.pthread_condattr_init
665+
libc.src.pthread.pthread_condattr_setclock
666+
libc.src.pthread.pthread_condattr_setpshared
602667
libc.src.pthread.pthread_create
603668
libc.src.pthread.pthread_detach
604669
libc.src.pthread.pthread_equal
@@ -621,6 +686,21 @@ if(LLVM_LIBC_FULL_BUILD)
621686
libc.src.pthread.pthread_mutexattr_setrobust
622687
libc.src.pthread.pthread_mutexattr_settype
623688
libc.src.pthread.pthread_once
689+
libc.src.pthread.pthread_rwlock_destroy
690+
libc.src.pthread.pthread_rwlock_init
691+
libc.src.pthread.pthread_rwlock_rdlock
692+
libc.src.pthread.pthread_rwlock_timedrdlock
693+
libc.src.pthread.pthread_rwlock_timedwrlock
694+
libc.src.pthread.pthread_rwlock_tryrdlock
695+
libc.src.pthread.pthread_rwlock_trywrlock
696+
libc.src.pthread.pthread_rwlock_unlock
697+
libc.src.pthread.pthread_rwlock_wrlock
698+
libc.src.pthread.pthread_rwlockattr_destroy
699+
libc.src.pthread.pthread_rwlockattr_getkind_np
700+
libc.src.pthread.pthread_rwlockattr_getpshared
701+
libc.src.pthread.pthread_rwlockattr_init
702+
libc.src.pthread.pthread_rwlockattr_setkind_np
703+
libc.src.pthread.pthread_rwlockattr_setpshared
624704
libc.src.pthread.pthread_self
625705
libc.src.pthread.pthread_setname_np
626706
libc.src.pthread.pthread_setspecific
@@ -644,7 +724,6 @@ if(LLVM_LIBC_FULL_BUILD)
644724
libc.src.stdio.fgetc
645725
libc.src.stdio.fgetc_unlocked
646726
libc.src.stdio.fgets
647-
libc.src.stdio.fileno
648727
libc.src.stdio.flockfile
649728
libc.src.stdio.fopen
650729
libc.src.stdio.fopencookie
@@ -653,7 +732,9 @@ if(LLVM_LIBC_FULL_BUILD)
653732
libc.src.stdio.fread
654733
libc.src.stdio.fread_unlocked
655734
libc.src.stdio.fseek
735+
libc.src.stdio.fseeko
656736
libc.src.stdio.ftell
737+
libc.src.stdio.ftello
657738
libc.src.stdio.funlockfile
658739
libc.src.stdio.fwrite
659740
libc.src.stdio.fwrite_unlocked
@@ -674,9 +755,11 @@ if(LLVM_LIBC_FULL_BUILD)
674755
# stdlib.h entrypoints
675756
libc.src.stdlib._Exit
676757
libc.src.stdlib.abort
758+
libc.src.stdlib.at_quick_exit
677759
libc.src.stdlib.atexit
678760
libc.src.stdlib.exit
679761
libc.src.stdlib.getenv
762+
libc.src.stdlib.quick_exit
680763

681764
# signal.h entrypoints
682765
libc.src.signal.kill
@@ -758,6 +841,10 @@ if(LLVM_LIBC_FULL_BUILD)
758841

759842
# sys/select.h entrypoints
760843
libc.src.sys.select.select
844+
845+
# sys/socket.h entrypoints
846+
libc.src.sys.socket.bind
847+
libc.src.sys.socket.socket
761848
)
762849
endif()
763850

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ set(TARGET_LIBC_ENTRYPOINTS
228228
libc.src.sys.epoll.epoll_ctl
229229
libc.src.sys.epoll.epoll_pwait
230230
libc.src.sys.epoll.epoll_wait
231-
# TODO: Need to check if pwait2 is available before providing.
232-
# https://github.com/llvm/llvm-project/issues/80060
233-
# libc.src.sys.epoll.epoll_pwait2
231+
libc.src.sys.epoll.epoll_pwait2
234232

235233
# sys/mman.h entrypoints
236234
libc.src.sys.mman.madvise

libc/src/__support/File/file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ int File::ungetc_unlocked(int c) {
282282
return c;
283283
}
284284

285-
ErrorOr<int> File::seek(long offset, int whence) {
285+
ErrorOr<int> File::seek(off_t offset, int whence) {
286286
FileLock lock(this);
287287
if (prev_op == FileOp::WRITE && pos > 0) {
288288

libc/src/__support/File/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class File {
183183
return read_unlocked(data, len);
184184
}
185185

186-
ErrorOr<int> seek(long offset, int whence);
186+
ErrorOr<int> seek(off_t offset, int whence);
187187

188188
ErrorOr<off_t> tell();
189189

libc/test/src/__support/File/platform_file_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ TEST(LlvmLibcPlatformFileTest, CreateAppendSeekAndReadBack) {
103103
constexpr size_t APPEND_TEXT_SIZE = sizeof(APPEND_TEXT) - 1;
104104
ASSERT_EQ(file->write(APPEND_TEXT, APPEND_TEXT_SIZE).value, APPEND_TEXT_SIZE);
105105

106-
ASSERT_EQ(file->seek(-APPEND_TEXT_SIZE, SEEK_END).value(), 0);
106+
ASSERT_EQ(file->seek(-static_cast<off_t>(APPEND_TEXT_SIZE), SEEK_END).value(),
107+
0);
107108
char data[APPEND_TEXT_SIZE + 1];
108109
ASSERT_EQ(file->read(data, APPEND_TEXT_SIZE).value, APPEND_TEXT_SIZE);
109110
data[APPEND_TEXT_SIZE] = '\0';

0 commit comments

Comments
 (0)