Skip to content

Commit

Permalink
Pull latest
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhinavMir committed Feb 5, 2024
2 parents e90613e + 8df6648 commit 375ccb8
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/services/portability/posix/option_groups/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ _XOPEN_STREAMS
isastream(),
putmsg(),
putpmsg(),
putpmsg(),


.. _Subprofiling Considerations:
Expand Down
2 changes: 2 additions & 0 deletions include/zephyr/posix/stropts.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct strbuf {

int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags);

int putpmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int band, int flags);

#ifdef __cplusplus
}
#endif
Expand Down
67 changes: 67 additions & 0 deletions lib/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,70 @@

add_subdirectory(options)
add_subdirectory(shell)

zephyr_syscall_header(
posix_clock.h
)

zephyr_interface_library_named(posix_subsys)

if(CONFIG_POSIX_API)
zephyr_include_directories(${ZEPHYR_BASE}/include/zephyr/posix)
endif()

if(CONFIG_POSIX_SIGNAL)
set(STRSIGNAL_TABLE_H ${GEN_DIR}/posix/strsignal_table.h)

add_custom_command(
OUTPUT ${STRSIGNAL_TABLE_H}
COMMAND
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/build/gen_strsignal_table.py
-i ${ZEPHYR_BASE}/include/zephyr/posix/signal.h
-o ${STRSIGNAL_TABLE_H}
DEPENDS ${ZEPHYR_BASE}/include/zephyr/posix/signal.h
)
endif()

if(CONFIG_POSIX_API OR CONFIG_PTHREAD_IPC OR CONFIG_POSIX_CLOCK OR
CONFIG_POSIX_MQUEUE OR CONFIG_POSIX_FS OR CONFIG_EVENTFD OR CONFIG_GETOPT)
# This is a temporary workaround so that Newlib declares the appropriate
# types for us. POSIX features to be formalized as part of #51211
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:-D_POSIX_THREADS>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_POSIX_THREADS>)
endif()

zephyr_library()
add_subdirectory_ifdef(CONFIG_GETOPT getopt)
add_subdirectory_ifdef(CONFIG_SHELL shell)
zephyr_library_sources_ifdef(CONFIG_EVENTFD eventfd.c)
zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_API perror.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK nanosleep.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_FS fs.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_MQUEUE mqueue.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNAL signal.c ${STRSIGNAL_TABLE_H})
zephyr_library_sources_ifdef(CONFIG_POSIX_UNAME uname.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC _common.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_BARRIER barrier.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_COND cond.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_KEY key.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_MUTEX mutex.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD pthread.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_RWLOCK rwlock.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_SPINLOCK spinlock.c)
zephyr_library_sources_ifdef(CONFIG_TIMER timer.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_PUTMSG stropts.c)
zephyr_library_source_ifdef(CONFIG_POSIX_PUTPMSG stropts.c)

zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ARCH_DIR}/${ARCH}/include
)

zephyr_library_link_libraries(posix_subsys)
zephyr_library_property(ALLOW_EMPTY TRUE)
6 changes: 6 additions & 0 deletions lib/posix/options/Kconfig.stropts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ config POSIX_PUTMSG
default y if POSIX_API
help
This option provides support for the putmsg function used in message passing.

config POSIX_PUTPMSG
bool "Support for putpmsg function"
default y if POSIX_API
help
This option provides support for the putpmsg function used in message passing.
13 changes: 13 additions & 0 deletions lib/posix/options/stropts.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr
errno = ENOSYS;
return -1;
}

int putpmsg(int fildes, const struct strbuf *ctlptr,
const struct strbuf *dataptr, int band, int flags)
{
ARG_UNUSED(fildes);
ARG_UNUSED(ctlptr);
ARG_UNUSED(dataptr);
ARG_UNUSED(band);
ARG_UNUSED(flags);

errno = ENOSYS;
return -1;
}
12 changes: 12 additions & 0 deletions tests/posix/common/src/stropts.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ ZTEST(stropts, test_putmsg)
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST(stropts, test_putpmsg)
{
const struct strbuf *ctrl = NULL;
const struct strbuf *data = NULL;
int fd = -1;
int band = 0;
int ret = putpmsg(fd, ctrl, data, band, 0);

zassert_equal(ret, -1, "Expected return value -1, got %d", ret);
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST_SUITE(stropts, NULL, NULL, NULL, NULL, NULL);
7 changes: 7 additions & 0 deletions tests/posix/headers/src/stropts_h.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ ZTEST(posix_headers, test_stropts_h)
zassert_not_equal(RS_HIPRI, ~RS_HIPRI);
#endif
}

ZTEST(posix_headers, test_stropts_h_putpmsg)
{
#ifdef CONFIG_POSIX_API
zassert_not_null((void *)putpmsg, "putpmsg is null");
#endif
}

0 comments on commit 375ccb8

Please sign in to comment.