Unverified Commit ddc30ff8 authored by Joseph Huber's avatar Joseph Huber Committed by GitHub
Browse files

[libc] Implement the 'ungetc' function on the GPU (#69248)

Summary:
This function follows closely with the pattern of all the other
functions. That is, making a new opcode and forwarding the call to the
host. However, this also required modifying the test somewhat. It seems
that not all `libc` implementations follow the same error rules as are
tested here, and it is not explicit in the standard, so we simply
disable these EOF checks when targeting the GPU.
parent 761c9dd9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ set(TARGET_LIBC_ENTRYPOINTS
    libc.src.stdio.fgetc
    libc.src.stdio.getc
    libc.src.stdio.getchar
    libc.src.stdio.ungetc
    libc.src.stdio.stdin
    libc.src.stdio.stdout
    libc.src.stdio.stderr
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ ftell |check| |check|
fflush         |check|    |check|
fgetc          |check|    |check|
fgets          |check|    |check|
ungetc         |check|    |check|
getc           |check|    |check|
getchar        |check|    |check|
puts           |check|    |check|
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ typedef enum {
  RPC_FSEEK,
  RPC_FTELL,
  RPC_FFLUSH,
  RPC_UNGETC,
  RPC_LAST = 0xFFFF,
} rpc_opcode_t;

+1 −12
Original line number Diff line number Diff line
@@ -54,18 +54,6 @@ add_entrypoint_object(
    libc.src.__support.File.platform_file
)

add_entrypoint_object(
  ungetc
  SRCS
    ungetc.cpp
  HDRS
    ungetc.h
  DEPENDS
    libc.include.stdio
    libc.src.__support.File.file
    libc.src.__support.File.platform_file
)

add_entrypoint_object(
  fopencookie
  SRCS
@@ -286,6 +274,7 @@ add_stdio_entrypoint_object(getc_unlocked)
add_stdio_entrypoint_object(getchar)
add_stdio_entrypoint_object(getchar_unlocked)
add_stdio_entrypoint_object(fgets)
add_stdio_entrypoint_object(ungetc)
add_stdio_entrypoint_object(stdin)
add_stdio_entrypoint_object(stdout)
add_stdio_entrypoint_object(stderr)
+12 −0
Original line number Diff line number Diff line
@@ -342,6 +342,18 @@ add_entrypoint_object(
    libc.src.__support.File.platform_file
)

add_entrypoint_object(
  ungetc
  SRCS
    ungetc.cpp
  HDRS
    ../ungetc.h
  DEPENDS
    libc.include.stdio
    libc.src.__support.File.file
    libc.src.__support.File.platform_file
)

add_entrypoint_object(
  stdin
  SRCS
Loading