Revert "posix: getopt: move declarations to unistd.h"
This seems to have caused build failures in spite of CI being
green in PR 52653.
This reverts commit fc92eb1b37
.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
This commit is contained in:
parent
cdc0f30dbb
commit
4d906d944b
|
@ -43,12 +43,6 @@ static inline int gethostname(char *buf, size_t len)
|
||||||
|
|
||||||
#endif /* CONFIG_POSIX_API */
|
#endif /* CONFIG_POSIX_API */
|
||||||
|
|
||||||
#ifdef CONFIG_GETOPT
|
|
||||||
int getopt(int argc, char *const argv[], const char *optstring);
|
|
||||||
extern char *optarg;
|
|
||||||
extern int opterr, optind, optopt;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned sleep(unsigned int seconds);
|
unsigned sleep(unsigned int seconds);
|
||||||
int usleep(useconds_t useconds);
|
int usleep(useconds_t useconds);
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef CONFIG_ARCH_POSIX
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <zephyr/posix/unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/shell/shell.h>
|
#include <zephyr/shell/shell.h>
|
||||||
|
@ -75,6 +71,7 @@ static int cmd_crc(const struct shell *sh, size_t argc, char **argv)
|
||||||
enum crc_type type = CRC32_IEEE;
|
enum crc_type type = CRC32_IEEE;
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
optreset = 1;
|
||||||
|
|
||||||
while ((rv = getopt(argc, argv, "fhlp:rs:t:")) != -1) {
|
while ((rv = getopt(argc, argv, "fhlp:rs:t:")) != -1) {
|
||||||
switch (rv) {
|
switch (rv) {
|
||||||
|
|
|
@ -30,11 +30,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef CONFIG_ARCH_POSIX
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <zephyr/posix/unistd.h>
|
|
||||||
#endif
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
#include "getopt_common.h"
|
#include "getopt_common.h"
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,11 @@ struct getopt_state {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern int opterr; /* if error message should be printed */
|
||||||
|
extern int optind; /* index into parent argv vector */
|
||||||
|
extern int optopt; /* character checked for validity */
|
||||||
extern int optreset; /* reset getopt */
|
extern int optreset; /* reset getopt */
|
||||||
|
extern char *optarg; /* argument associated with option */
|
||||||
|
|
||||||
#define no_argument 0
|
#define no_argument 0
|
||||||
#define required_argument 1
|
#define required_argument 1
|
||||||
|
@ -54,6 +58,27 @@ void getopt_init(void);
|
||||||
/* Function returns getopt_state structure for the current thread. */
|
/* Function returns getopt_state structure for the current thread. */
|
||||||
struct getopt_state *getopt_state_get(void);
|
struct getopt_state *getopt_state_get(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses the command-line arguments.
|
||||||
|
*
|
||||||
|
* It is based on FreeBSD implementation.
|
||||||
|
*
|
||||||
|
* @param[in] argc Arguments count.
|
||||||
|
* @param[in] argv Arguments.
|
||||||
|
* @param[in] options String containing the legitimate option characters.
|
||||||
|
*
|
||||||
|
* @return If an option was successfully found, function returns
|
||||||
|
* the option character.
|
||||||
|
* @return If options have been detected that is not in @p options
|
||||||
|
* function will return '?'.
|
||||||
|
* If function encounters an option with a missing
|
||||||
|
* argument, then the return value depends on the first
|
||||||
|
* character in optstring: if it is ':', then ':' is
|
||||||
|
* returned; otherwise '?' is returned.
|
||||||
|
* @return -1 If all options have been parsed.
|
||||||
|
*/
|
||||||
|
int getopt(int nargc, char *const nargv[], const char *ostr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses the command-line arguments.
|
* @brief Parses the command-line arguments.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,12 +13,6 @@
|
||||||
#include <zephyr/usb/usb_device.h>
|
#include <zephyr/usb/usb_device.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_POSIX
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <zephyr/posix/unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(app);
|
LOG_MODULE_REGISTER(app);
|
||||||
|
|
||||||
extern void foo(void);
|
extern void foo(void);
|
||||||
|
|
Loading…
Reference in a new issue