-
Notifications
You must be signed in to change notification settings - Fork 7.4k
posix: implement putmsg() #67711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
posix: implement putmsg() #67711
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2024 Abhinav Srivastava | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef ZEPHYR_INCLUDE_POSIX_STROPTS_H_ | ||
#define ZEPHYR_INCLUDE_POSIX_STROPTS_H_ | ||
#define RS_HIPRI BIT(0) | ||
|
||
AbhinavMir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
struct strbuf { | ||
int maxlen; | ||
int len; | ||
char *buf; | ||
}; | ||
|
||
int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
AbhinavMir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif /* ZEPHYR_INCLUDE_POSIX_STROPTS_H_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# copyright (c) 2024 Abhinav Srivastava | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config POSIX_PUTMSG | ||
bool "Support for putmsg function" | ||
default y if POSIX_API | ||
help | ||
This option provides support for the putmsg function used in message passing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2024 Abhinav Srivastava | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/posix/stropts.h> | ||
#include <errno.h> | ||
#include <zephyr/kernel.h> | ||
|
||
cfriedt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags) | ||
{ | ||
ARG_UNUSED(fildes); | ||
ARG_UNUSED(ctlptr); | ||
ARG_UNUSED(dataptr); | ||
ARG_UNUSED(flags); | ||
|
||
errno = ENOSYS; | ||
return -1; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2024 Abhinav Srivastava | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <zephyr/ztest.h> | ||
#include <stropts.h> | ||
#include <errno.h> | ||
|
||
ZTEST(stropts, test_putmsg) | ||
{ | ||
const struct strbuf *ctrl = NULL; | ||
const struct strbuf *data = NULL; | ||
int fd = -1; | ||
int ret = putmsg(fd, ctrl, data, 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2024 Abhinav Srivastava | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "_common.h" | ||
#ifdef CONFIG_POSIX_API | ||
#include <stropts.h> | ||
#else | ||
#include <zephyr/posix/stropts.h> | ||
#endif | ||
|
||
/** | ||
* @brief Test existence and basic functionality of stropts.h | ||
* | ||
* @see stropts.h | ||
*/ | ||
ZTEST(posix_headers, test_stropts_h) | ||
{ | ||
#ifdef CONFIG_POSIX_API | ||
zassert_not_null((void *)putmsg, "putmsg is null"); | ||
AbhinavMir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
zassert_true(sizeof(((struct strbuf *)0)->maxlen) > 0, "maxlen size is 0"); | ||
zassert_true(sizeof(((struct strbuf *)0)->len) > 0, "len size is 0"); | ||
zassert_true(sizeof(((struct strbuf *)0)->buf) > 0, "buf size is 0"); | ||
zassert_not_equal(RS_HIPRI, ~RS_HIPRI); | ||
#endif | ||
} | ||
AbhinavMir marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.