Changeset 75c430e3 in mainline for uspace/lib/posix/src/stdlib.c
- Timestamp:
- 2018-06-19T11:48:03Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 47be512
- Parents:
- 6c440362
- git-author:
- Jiri Svoboda <jiri@…> (2018-06-18 17:47:07)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-06-19 11:48:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/src/stdlib.c
r6c440362 r75c430e3 84 84 85 85 /** 86 * Binary search in a sorted array.87 *88 * @param key Object to search for.89 * @param base Pointer to the first element of the array.90 * @param nmemb Number of elements in the array.91 * @param size Size of each array element.92 * @param compar Comparison function.93 * @return Pointer to a matching element, or NULL if none can be found.94 */95 void *bsearch(const void *key, const void *base,96 size_t nmemb, size_t size, int (*compar)(const void *, const void *))97 {98 while (nmemb > 0) {99 const void *middle = base + (nmemb / 2) * size;100 int cmp = compar(key, middle);101 if (cmp == 0) {102 return (void *) middle;103 }104 if (middle == base) {105 /*106 * There is just one member left to check and it107 * didn't match the key. Avoid infinite loop.108 */109 break;110 }111 if (cmp < 0) {112 nmemb = nmemb / 2;113 } else if (cmp > 0) {114 nmemb = nmemb - (nmemb / 2);115 base = middle;116 }117 }118 119 return NULL;120 }121 122 /**123 * Retrieve a value of the given environment variable.124 *125 * Since HelenOS doesn't support env variables at the moment,126 * this function always returns NULL.127 *128 * @param name Name of the variable.129 * @return Value of the variable or NULL if such variable does not exist.130 */131 char *getenv(const char *name)132 {133 return NULL;134 }135 136 /**137 86 * 138 87 * @param name … … 143 92 { 144 93 // TODO: low priority, just a compile-time dependency of binutils 145 not_implemented();146 return 0;147 }148 149 /**150 * Issue a command.151 *152 * @param string String to be passed to a command interpreter or NULL.153 * @return Termination status of the command if the command is not NULL,154 * otherwise indicate whether there is a command interpreter (non-zero)155 * or not (zero).156 */157 int system(const char *string)158 {159 // TODO: does nothing at the moment160 94 not_implemented(); 161 95 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.