Skip to content

Commit 4bc8fa7

Browse files
[libc] Enable most of the libc entrypoitns for riscv
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 4d8e42e commit 4bc8fa7

File tree

5 files changed

+103
-16
lines changed

5 files changed

+103
-16
lines changed

libc/config/linux/riscv/entrypoints.txt

Lines changed: 98 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
@@ -302,6 +315,7 @@ set(TARGET_LIBC_ENTRYPOINTS
302315
libc.src.unistd.linkat
303316
libc.src.unistd.lseek
304317
libc.src.unistd.pathconf
318+
libc.src.unistd.pipe
305319
libc.src.unistd.pread
306320
libc.src.unistd.pwrite
307321
libc.src.unistd.read
@@ -347,6 +361,9 @@ set(TARGET_LIBM_ENTRYPOINTS
347361
libc.src.math.atan2f
348362
libc.src.math.atanf
349363
libc.src.math.atanhf
364+
libc.src.math.canonicalize
365+
libc.src.math.canonicalizef
366+
libc.src.math.canonicalizel
350367
libc.src.math.cbrt
351368
libc.src.math.cbrtf
352369
libc.src.math.ceil
@@ -365,6 +382,7 @@ set(TARGET_LIBM_ENTRYPOINTS
365382
libc.src.math.exp10f
366383
libc.src.math.exp2
367384
libc.src.math.exp2f
385+
libc.src.math.exp2m1f
368386
libc.src.math.expf
369387
libc.src.math.expm1
370388
libc.src.math.expm1f
@@ -492,6 +510,9 @@ set(TARGET_LIBM_ENTRYPOINTS
492510
libc.src.math.rintf
493511
libc.src.math.rintl
494512
libc.src.math.round
513+
libc.src.math.roundeven
514+
libc.src.math.roundevenf
515+
libc.src.math.roundevenl
495516
libc.src.math.roundf
496517
libc.src.math.roundl
497518
libc.src.math.scalbn
@@ -523,8 +544,10 @@ set(TARGET_LIBM_ENTRYPOINTS
523544
if(LIBC_TYPES_HAS_FLOAT128)
524545
list(APPEND TARGET_LIBM_ENTRYPOINTS
525546
# math.h C23 _Float128 entrypoints
547+
libc.src.math.canonicalizef128
526548
libc.src.math.ceilf128
527549
libc.src.math.copysignf128
550+
libc.src.math.dmulf128
528551
libc.src.math.fabsf128
529552
libc.src.math.fdimf128
530553
libc.src.math.floorf128
@@ -539,6 +562,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
539562
libc.src.math.fminimum_numf128
540563
libc.src.math.fminimumf128
541564
libc.src.math.fmodf128
565+
libc.src.math.fmulf128
542566
libc.src.math.frexpf128
543567
libc.src.math.fromfpf128
544568
libc.src.math.fromfpxf128
@@ -556,7 +580,9 @@ if(LIBC_TYPES_HAS_FLOAT128)
556580
libc.src.math.nextafterf128
557581
libc.src.math.nextdownf128
558582
libc.src.math.nextupf128
583+
libc.src.math.remquof128
559584
libc.src.math.rintf128
585+
libc.src.math.roundevenf128
560586
libc.src.math.roundf128
561587
libc.src.math.scalbnf128
562588
libc.src.math.sqrtf128
@@ -566,14 +592,48 @@ if(LIBC_TYPES_HAS_FLOAT128)
566592
)
567593
endif()
568594

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

634+
# compiler entrypoints (no corresponding header)
635+
libc.src.compiler.__stack_chk_fail
636+
577637
# dirent.h entrypoints
578638
libc.src.dirent.closedir
579639
libc.src.dirent.dirfd
@@ -598,6 +658,12 @@ if(LLVM_LIBC_FULL_BUILD)
598658
libc.src.pthread.pthread_attr_setguardsize
599659
libc.src.pthread.pthread_attr_setstack
600660
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
601667
libc.src.pthread.pthread_create
602668
libc.src.pthread.pthread_detach
603669
libc.src.pthread.pthread_equal
@@ -620,6 +686,21 @@ if(LLVM_LIBC_FULL_BUILD)
620686
libc.src.pthread.pthread_mutexattr_setrobust
621687
libc.src.pthread.pthread_mutexattr_settype
622688
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
623704
libc.src.pthread.pthread_self
624705
libc.src.pthread.pthread_setname_np
625706
libc.src.pthread.pthread_setspecific
@@ -643,7 +724,6 @@ if(LLVM_LIBC_FULL_BUILD)
643724
libc.src.stdio.fgetc
644725
libc.src.stdio.fgetc_unlocked
645726
libc.src.stdio.fgets
646-
libc.src.stdio.fileno
647727
libc.src.stdio.flockfile
648728
libc.src.stdio.fopen
649729
libc.src.stdio.fopencookie
@@ -652,7 +732,9 @@ if(LLVM_LIBC_FULL_BUILD)
652732
libc.src.stdio.fread
653733
libc.src.stdio.fread_unlocked
654734
libc.src.stdio.fseek
735+
libc.src.stdio.fseeko
655736
libc.src.stdio.ftell
737+
libc.src.stdio.ftello
656738
libc.src.stdio.funlockfile
657739
libc.src.stdio.fwrite
658740
libc.src.stdio.fwrite_unlocked
@@ -673,9 +755,11 @@ if(LLVM_LIBC_FULL_BUILD)
673755
# stdlib.h entrypoints
674756
libc.src.stdlib._Exit
675757
libc.src.stdlib.abort
758+
libc.src.stdlib.at_quick_exit
676759
libc.src.stdlib.atexit
677760
libc.src.stdlib.exit
678761
libc.src.stdlib.getenv
762+
libc.src.stdlib.quick_exit
679763

680764
# signal.h entrypoints
681765
libc.src.signal.kill
@@ -757,6 +841,10 @@ if(LLVM_LIBC_FULL_BUILD)
757841

758842
# sys/select.h entrypoints
759843
libc.src.sys.select.select
844+
845+
# sys/socket.h entrypoints
846+
libc.src.sys.socket.bind
847+
libc.src.sys.socket.socket
760848
)
761849
endif()
762850

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)