Changeset 7c3fb9b in mainline for uspace/lib/bithenge/src
- Timestamp:
- 2018-05-17T08:29:01Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6ff23ff
- Parents:
- fac0ac7
- git-author:
- Jiri Svoboda <jiri@…> (2018-05-16 17:28:17)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-05-17 08:29:01)
- Location:
- uspace/lib/bithenge/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/src/blob.c
rfac0ac7 r7c3fb9b 239 239 * @param needs_free If true, the buffer will be freed with free() if this 240 240 * function fails or the blob is destroyed. 241 * @return EOK on success or an error code from errno.h. */ 241 * @return EOK on success or an error code from errno.h. 242 */ 242 243 errno_t bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer, 243 244 size_t len, bool needs_free) … … 277 278 * @param[in] data The data. 278 279 * @param len The length of the data. 279 * @return EOK on success or an error code from errno.h. */ 280 * @return EOK on success or an error code from errno.h. 281 */ 280 282 errno_t bithenge_new_blob_from_data(bithenge_node_t **out, const void *data, 281 283 size_t len) … … 435 437 * @param[in] source The input blob. 436 438 * @param offset The offset within the input blob at which the new blob will start. 437 * @return EOK on success or an error code from errno.h. */ 439 * @return EOK on success or an error code from errno.h. 440 */ 438 441 errno_t bithenge_new_offset_blob(bithenge_node_t **out, bithenge_blob_t *source, 439 442 aoff64_t offset) … … 448 451 * @param offset The offset within the input blob at which the new blob will start. 449 452 * @param size The size of the new blob. 450 * @return EOK on success or an error code from errno.h. */ 453 * @return EOK on success or an error code from errno.h. 454 */ 451 455 errno_t bithenge_new_subblob(bithenge_node_t **out, bithenge_blob_t *source, 452 456 aoff64_t offset, aoff64_t size) -
uspace/lib/bithenge/src/compound.c
rfac0ac7 r7c3fb9b 115 115 * @param[in] xforms The transforms to apply. 116 116 * @param num The number of transforms. 117 * @return EOK on success or an error code from errno.h. */ 117 * @return EOK on success or an error code from errno.h. 118 */ 118 119 errno_t bithenge_new_composed_transform(bithenge_transform_t **out, 119 120 bithenge_transform_t **xforms, size_t num) … … 231 232 * @param true_xform The transform to apply if the expression is true. 232 233 * @param false_xform The transform to apply if the expression is false. 233 * @return EOK on success or an error code from errno.h. */ 234 * @return EOK on success or an error code from errno.h. 235 */ 234 236 errno_t bithenge_if_transform(bithenge_transform_t **out, 235 237 bithenge_expression_t *expr, bithenge_transform_t *true_xform, … … 309 311 * @param[out] out Holds the new transform. 310 312 * @param xform The subtransform to apply. 311 * @return EOK on success or an error code from errno.h. */ 313 * @return EOK on success or an error code from errno.h. 314 */ 312 315 errno_t bithenge_partial_transform(bithenge_transform_t **out, 313 316 bithenge_transform_t *xform) -
uspace/lib/bithenge/src/expression.c
rfac0ac7 r7c3fb9b 47 47 * @param[out] self Expression to initialize. 48 48 * @param[in] ops Operations provided by the expression. 49 * @return EOK or an error code from errno.h. */ 49 * @return EOK or an error code from errno.h. 50 */ 50 51 errno_t bithenge_init_expression(bithenge_expression_t *self, 51 52 const bithenge_expression_ops_t *ops) … … 156 157 break; 157 158 case BITHENGE_EXPRESSION_INTEGER_DIVIDE: 158 /* Integer division can behave in three major ways when the 159 operands are signed: truncated, floored, or Euclidean. When 159 /* 160 * Integer division can behave in three major ways when the 161 * operands are signed: truncated, floored, or Euclidean. When 160 162 * b > 0, we give the same result as floored and Euclidean; 161 163 * otherwise, we currently raise an error. See 162 164 * https://en.wikipedia.org/wiki/Modulo_operation and its 163 * references. */ 165 * references. 166 */ 164 167 if (b_int <= 0) { 165 168 rc = EINVAL; … … 249 252 * @param a The first operand. 250 253 * @param b The second operand. 251 * @return EOK on success or an error code from errno.h. */ 254 * @return EOK on success or an error code from errno.h. 255 */ 252 256 errno_t bithenge_binary_expression(bithenge_expression_t **out, 253 257 bithenge_binary_op_t op, bithenge_expression_t *a, … … 305 309 /** Create an expression that gets the current input node. 306 310 * @param[out] out Holds the new expression. 307 * @return EOK on success or an error code from errno.h. */ 311 * @return EOK on success or an error code from errno.h. 312 */ 308 313 errno_t bithenge_in_node_expression(bithenge_expression_t **out) 309 314 { … … 339 344 /** Create an expression that gets the current node being created. 340 345 * @param[out] out Holds the new expression. 341 * @return EOK on success or an error code from errno.h. */ 346 * @return EOK on success or an error code from errno.h. 347 */ 342 348 errno_t bithenge_current_node_expression(bithenge_expression_t **out) 343 349 { … … 389 395 * @param[out] out Holds the created expression. 390 396 * @param index The index of the parameter to get. 391 * @return EOK on success or an error code from errno.h. */ 397 * @return EOK on success or an error code from errno.h. 398 */ 392 399 errno_t bithenge_param_expression(bithenge_expression_t **out, int index) 393 400 { … … 454 461 * @param[out] out Holds the created expression. 455 462 * @param node The constant. 456 * @return EOK on success or an error code from errno.h. */ 463 * @return EOK on success or an error code from errno.h. 464 */ 457 465 errno_t bithenge_const_expression(bithenge_expression_t **out, 458 466 bithenge_node_t *node) … … 536 544 * @param[out] out Holds the new expression. 537 545 * @param key The key to search for in nodes being created. 538 * @return EOK on success or an error code from errno.h. */ 546 * @return EOK on success or an error code from errno.h. 547 */ 539 548 errno_t bithenge_scope_member_expression(bithenge_expression_t **out, 540 549 bithenge_node_t *key) … … 657 666 * @param absolute_limit If true, the limit is an absolute offset; otherwise, 658 667 * it is relative to the start. 659 * @return EOK on success or an error code from errno.h. */ 668 * @return EOK on success or an error code from errno.h. 669 */ 660 670 errno_t bithenge_subblob_expression(bithenge_expression_t **out, 661 671 bithenge_expression_t *blob, bithenge_expression_t *start, … … 815 825 * @param transform The transform for which parameters are calculated. 816 826 * @param params The expressions used to calculate the parameters. 817 * @return EOK on success or an error code from errno.h. */ 827 * @return EOK on success or an error code from errno.h. 828 */ 818 829 errno_t bithenge_param_wrapper(bithenge_transform_t **out, 819 830 bithenge_transform_t *transform, bithenge_expression_t **params) … … 899 910 * @param[out] out Holds the new transform. 900 911 * @param expr The expression to evaluate. 901 * @return EOK on success or an error code from errno.h. */ 912 * @return EOK on success or an error code from errno.h. 913 */ 902 914 errno_t bithenge_expression_transform(bithenge_transform_t **out, 903 915 bithenge_expression_t *expr) … … 956 968 * @param[out] out Holds the new transform. 957 969 * @param expr The expression to evaluate. 958 * @return EOK on success or an error code from errno.h. */ 970 * @return EOK on success or an error code from errno.h. 971 */ 959 972 errno_t bithenge_inputless_transform(bithenge_transform_t **out, 960 973 bithenge_expression_t *expr) … … 1117 1130 * @param a The first blob. 1118 1131 * @param b The second blob. 1119 * @return EOK on success or an error code from errno.h. */ 1132 * @return EOK on success or an error code from errno.h. 1133 */ 1120 1134 errno_t bithenge_concat_blob(bithenge_node_t **out, bithenge_blob_t *a, 1121 1135 bithenge_blob_t *b) … … 1159 1173 * @param b_expr An expression to calculate the second blob. 1160 1174 * @param scope The scope in which @a b_expr should be evaluated. 1161 * @return EOK on success or an error code from errno.h. */ 1175 * @return EOK on success or an error code from errno.h. 1176 */ 1162 1177 errno_t bithenge_concat_blob_lazy(bithenge_node_t **out, bithenge_blob_t *a, 1163 1178 bithenge_expression_t *b_expr, bithenge_scope_t *scope) -
uspace/lib/bithenge/src/failure.c
rfac0ac7 r7c3fb9b 47 47 #include "common.h" 48 48 49 /* This file raises fake errors from system calls, to test that Bithenge 49 /* 50 * This file raises fake errors from system calls, to test that Bithenge 50 51 * handles the errors correctly. It has two primary modes of operation, 51 52 * depending on an environment variable: … … 60 61 * BITHENGE_FAILURE_INDEX set: the program runs normally until system call 61 62 * number BITHENGE_FAILURE_INDEX is made; a fake error is returned from this 62 * call. */ 63 * call. 64 */ 63 65 64 66 static int g_initialized = 0; … … 94 96 } 95 97 96 /* Record a hit for a backtrace address and return whether this is the first 97 * hit. */ 98 /* 99 * Record a hit for a backtrace address and return whether this is the first 100 * hit. 101 */ 98 102 static inline errno_t backtrace_item_hit(void *addr) 99 103 { … … 133 137 } 134 138 135 /* If all backtrace items have been seen already, there's no need to 136 * try raising an error. */ 139 /* 140 * If all backtrace items have been seen already, there's no need to 141 * try raising an error. 142 */ 137 143 void *trace[256]; 138 144 int size = backtrace(trace, 256); … … 162 168 return 0; 163 169 164 /* The child had an error! We couldn't easily debug it because it was 170 /* 171 * The child had an error! We couldn't easily debug it because it was 165 172 * in a separate process with redirected stdout and stderr. Do it again 166 * without redirecting or forking. */ 173 * without redirecting or forking. 174 */ 167 175 fprintf(stderr, "** Fake error raised here (BITHENGE_FAILURE_INDEX=%d)\n", 168 176 g_failure_index); -
uspace/lib/bithenge/src/file.c
rfac0ac7 r7c3fb9b 140 140 * @param[out] out Stores the created blob. 141 141 * @param filename The name of the file. 142 * @return EOK on success or an error code from errno.h. */ 142 * @return EOK on success or an error code from errno.h. 143 */ 143 144 errno_t bithenge_new_file_blob(bithenge_node_t **out, const char *filename) 144 145 { … … 157 158 * @param[out] out Stores the created blob. 158 159 * @param fd The file descriptor. 159 * @return EOK on success or an error code from errno.h. */ 160 * @return EOK on success or an error code from errno.h. 161 */ 160 162 errno_t bithenge_new_file_blob_from_fd(bithenge_node_t **out, int fd) 161 163 { … … 167 169 * @param[out] out Stores the created blob. 168 170 * @param file The file pointer. 169 * @return EOK on success or an error code from errno.h. */ 171 * @return EOK on success or an error code from errno.h. 172 */ 170 173 errno_t bithenge_new_file_blob_from_file(bithenge_node_t **out, FILE *file) 171 174 { -
uspace/lib/bithenge/src/helenos/block.c
rfac0ac7 r7c3fb9b 95 95 * @param[out] out Stores the created blob. 96 96 * @param service_id The service ID of the block device. 97 * @return EOK on success or an error code from errno.h. */ 97 * @return EOK on success or an error code from errno.h. 98 */ 98 99 errno_t bithenge_new_block_blob(bithenge_node_t **out, service_id_t service_id) 99 100 { -
uspace/lib/bithenge/src/print.c
rfac0ac7 r7c3fb9b 222 222 * @param type The format to use. 223 223 * @param tree The root node of the tree to print. 224 * @return EOK on success or an error code from errno.h. */ 224 * @return EOK on success or an error code from errno.h. 225 */ 225 226 errno_t bithenge_print_node(bithenge_print_type_t type, bithenge_node_t *tree) 226 227 { … … 236 237 * @param type The format to use. 237 238 * @param tree The root node of the tree to print. 238 * @return EOK on success or an error code from errno.h. */ 239 * @return EOK on success or an error code from errno.h. 240 */ 239 241 errno_t bithenge_print_node_to_string(char **str, size_t *size, 240 242 bithenge_print_type_t type, bithenge_node_t *tree) -
uspace/lib/bithenge/src/script.c
rfac0ac7 r7c3fb9b 55 55 /** @cond internal 56 56 * Single-character symbols are represented by the character itself. Every 57 * other token uses one of these values: */ 57 * other token uses one of these values: 58 */ 58 59 typedef enum { 59 60 TOKEN_ERROR = -128, … … 98 99 typedef struct { 99 100 /** Rather than constantly checking return values, the parser uses this 100 * to indicate whether an error has occurred. */ 101 * to indicate whether an error has occurred. 102 */ 101 103 errno_t error; 102 104 … … 109 111 FILE *file; 110 112 /** The buffer that holds script code. There is always a '\0' after the 111 * current position to prevent reading too far. */ 113 * current position to prevent reading too far. 114 */ 112 115 char buffer[BUFFER_SIZE]; 113 116 /** The start position within the buffer of the next unread token. */ … … 124 127 union { 125 128 /** The value of a TOKEN_IDENTIFIER token. Unless changed to 126 * NULL, it will be freed when the next token is read. */ 129 * NULL, it will be freed when the next token is read. 130 */ 127 131 char *token_string; 128 132 /** The value of a TOKEN_INTEGER token. */ … … 139 143 140 144 /** Free the previous token's data. This must be called before changing 141 * state->token. */ 145 * state->token. 146 */ 142 147 static void done_with_token(state_t *state) 143 148 { … … 346 351 /** Allocate memory and handle failure by setting the error in the state. The 347 352 * caller must check the state for errors before using the return value of this 348 * function. */ 353 * function. 354 */ 349 355 static void *state_malloc(state_t *state, size_t size) 350 356 { … … 358 364 359 365 /** Reallocate memory and handle failure by setting the error in the state. If 360 * an error occurs, the existing pointer will be returned. */ 366 * an error occurs, the existing pointer will be returned. 367 */ 361 368 static void *state_realloc(state_t *state, void *ptr, size_t size) 362 369 { … … 372 379 373 380 /** Expect and consume a certain token. If the next token is of the wrong type, 374 * an error is caused. */ 381 * an error is caused. 382 */ 375 383 static void expect(state_t *state, token_type_t type) 376 384 { … … 383 391 384 392 /** Expect and consume an identifier token. If the next token is not an 385 * identifier, an error is caused and this function returns null. */ 393 * identifier, an error is caused and this function returns null. 394 */ 386 395 static char *expect_identifier(state_t *state) 387 396 { … … 397 406 398 407 /** Find a transform by name. A reference will be added to the transform. 399 * @return The found transform, or NULL if none was found. */ 408 * @return The found transform, or NULL if none was found. 409 */ 400 410 static bithenge_transform_t *get_named_transform(state_t *state, 401 411 const char *name) … … 419 429 420 430 /** Add a named transform. This function takes ownership of the name and a 421 * reference to the transform. If an error has occurred, either may be null. */ 431 * reference to the transform. If an error has occurred, either may be null. 432 */ 422 433 static void add_named_transform(state_t *state, bithenge_transform_t *xform, char *name) 423 434 { … … 809 820 /** Create a transform that just produces an empty node. 810 821 * @param state The parser state. 811 * @return The new transform, or NULL on error. */ 822 * @return The new transform, or NULL on error. 823 */ 812 824 static bithenge_transform_t *make_empty_transform(state_t *state) 813 825 { … … 1139 1151 1140 1152 /** Parse a transform without composition. 1141 * @return The parsed transform, or NULL if an error occurred. */ 1153 * @return The parsed transform, or NULL if an error occurred. 1154 */ 1142 1155 static bithenge_transform_t *parse_transform_no_compose(state_t *state) 1143 1156 { … … 1188 1201 1189 1202 /** Parse a transform. 1190 * @return The parsed transform, or NULL if an error occurred. */ 1203 * @return The parsed transform, or NULL if an error occurred. 1204 */ 1191 1205 static bithenge_transform_t *parse_transform(state_t *state) 1192 1206 { … … 1320 1334 * @param[out] out Stores the "main" transform. 1321 1335 * @return EOK on success, EINVAL on syntax error, or an error code from 1322 * errno.h. */ 1336 * errno.h. 1337 */ 1323 1338 errno_t bithenge_parse_script(const char *filename, bithenge_transform_t **out) 1324 1339 { -
uspace/lib/bithenge/src/sequence.c
rfac0ac7 r7c3fb9b 150 150 151 151 if (index == self->num_ends) { 152 /* We can apply the subtransform and cache its prefix length at 153 * the same time. */ 152 /* 153 * We can apply the subtransform and cache its prefix length at 154 * the same time. 155 */ 154 156 bithenge_node_t *blob_node; 155 157 bithenge_blob_inc_ref(self->blob); … … 418 420 struct_node_t *node = node_as_struct(base); 419 421 420 /* Treat the scope carefully because of the circular reference. In 422 /* 423 * Treat the scope carefully because of the circular reference. In 421 424 * struct_transform_make_node, things are set up so node owns a 422 425 * reference to the scope, but scope doesn't own a reference to node, 423 * so node's reference count is too low. */ 426 * so node's reference count is too low. 427 */ 424 428 bithenge_scope_t *scope = seq_node_scope(struct_as_seq(node)); 425 429 if (scope->refs == 1) { 426 /* Mostly normal destroy, but we didn't inc_ref(node) for the 430 /* 431 * Mostly normal destroy, but we didn't inc_ref(node) for the 427 432 * scope in struct_transform_make_node, so make sure it doesn't 428 * try to dec_ref. */ 433 * try to dec_ref. 434 */ 429 435 scope->current_node = NULL; 430 436 seq_node_destroy(struct_as_seq(node)); 431 437 } else if (scope->refs > 1) { 432 /* The scope is still needed, but node isn't otherwise needed. 438 /* 439 * The scope is still needed, but node isn't otherwise needed. 433 440 * Switch things around so scope owns a reference to node, but 434 * not vice versa, and scope's reference count is too low. */ 441 * not vice versa, and scope's reference count is too low. 442 */ 435 443 bithenge_node_inc_ref(base); 436 444 bithenge_scope_dec_ref(scope); 437 445 return; 438 446 } else { 439 /* This happens after the previous case, when scope is no 447 /* 448 * This happens after the previous case, when scope is no 440 449 * longer used and is being destroyed. Since scope is already 441 450 * being destroyed, set it to NULL here so we don't try to 442 * destroy it twice. */ 451 * destroy it twice. 452 */ 443 453 struct_as_seq(node)->scope = NULL; 444 454 seq_node_destroy(struct_as_seq(node)); … … 501 511 node->prefix = prefix; 502 512 503 /* We should inc_ref(node) here, but that would make a cycle. Instead, 513 /* 514 * We should inc_ref(node) here, but that would make a cycle. Instead, 504 515 * we leave it 1 too low, so that when the only remaining use of node 505 516 * is the scope, node will be destroyed. Also see the comment in 506 * struct_node_destroy. */ 517 * struct_node_destroy. 518 */ 507 519 bithenge_scope_set_current_node(inner, struct_as_node(node)); 508 520 bithenge_scope_dec_ref(inner); … … 591 603 * @param[out] out Stores the created transform. 592 604 * @param subtransforms The subtransforms and field names. 593 * @return EOK on success or an error code from errno.h. */ 605 * @return EOK on success or an error code from errno.h. 606 */ 594 607 errno_t bithenge_new_struct(bithenge_transform_t **out, 595 608 bithenge_named_transform_t *subtransforms) … … 869 882 * @param expr Used to calculate the number of times @a xform will be applied. 870 883 * May be NULL, in which case @a xform will be applied indefinitely. 871 * @return EOK on success or an error code from errno.h. */ 884 * @return EOK on success or an error code from errno.h. 885 */ 872 886 errno_t bithenge_repeat_transform(bithenge_transform_t **out, 873 887 bithenge_transform_t *xform, bithenge_expression_t *expr) … … 1114 1128 * @param expr Applied in the result of each application of @a xform to 1115 1129 * determine whether there will be more. 1116 * @return EOK on success or an error code from errno.h. */ 1130 * @return EOK on success or an error code from errno.h. 1131 */ 1117 1132 errno_t bithenge_do_while_transform(bithenge_transform_t **out, 1118 1133 bithenge_transform_t *xform, bithenge_expression_t *expr) -
uspace/lib/bithenge/src/source.c
rfac0ac7 r7c3fb9b 84 84 * @param[out] out Stores the created node. 85 85 * @param source Specifies the node to be created. 86 * @return EOK on success or an error code from errno.h. */ 86 * @return EOK on success or an error code from errno.h. 87 */ 87 88 errno_t bithenge_node_from_source(bithenge_node_t **out, const char *source) 88 89 { -
uspace/lib/bithenge/src/transform.c
rfac0ac7 r7c3fb9b 56 56 * whatever parameters it has, so they can be passed to any param_wrappers 57 57 * within. 58 * @return EOK or an error code from errno.h. */ 58 * @return EOK or an error code from errno.h. 59 */ 59 60 errno_t bithenge_init_transform(bithenge_transform_t *self, 60 61 const bithenge_transform_ops_t *ops, int num_params) … … 82 83 * @param in The input tree. 83 84 * @param[out] out Where the output tree will be stored. 84 * @return EOK on success or an error code from errno.h. */ 85 * @return EOK on success or an error code from errno.h. 86 */ 85 87 errno_t bithenge_transform_apply(bithenge_transform_t *self, 86 88 bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out) … … 118 120 * @param[out] out Where the prefix length will be stored. 119 121 * @return EOK on success, ENOTSUP if not supported, or another error code from 120 * errno.h. */ 122 * errno.h. 123 */ 121 124 errno_t bithenge_transform_prefix_length(bithenge_transform_t *self, 122 125 bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out) … … 149 152 * case the size is not determined. 150 153 * @return EOK on success, ENOTSUP if not supported, or another error code from 151 * errno.h. */ 154 * errno.h. 155 */ 152 156 errno_t bithenge_transform_prefix_apply(bithenge_transform_t *self, 153 157 bithenge_scope_t *scope, bithenge_blob_t *blob, bithenge_node_t **out_node, … … 187 191 * @param[out] out Holds the new scope. 188 192 * @param outer The outer scope, or NULL. 189 * @return EOK on success or an error code from errno.h. */ 193 * @return EOK on success or an error code from errno.h. 194 */ 190 195 errno_t bithenge_scope_new(bithenge_scope_t **out, bithenge_scope_t *outer) 191 196 { … … 209 214 /** Dereference a transform scope. 210 215 * @memberof bithenge_scope_t 211 * @param self The scope to dereference, or NULL. */ 216 * @param self The scope to dereference, or NULL. 217 */ 212 218 void bithenge_scope_dec_ref(bithenge_scope_t *self) 213 219 { … … 228 234 * @memberof bithenge_scope_t 229 235 * @param self The scope to examine. 230 * @return The outer scope, which may be NULL. */ 236 * @return The outer scope, which may be NULL. 237 */ 231 238 bithenge_scope_t *bithenge_scope_outer(bithenge_scope_t *self) 232 239 { … … 238 245 * @memberof bithenge_scope_t 239 246 * @param scope The scope to get the error message from. 240 * @return The error message, or NULL. */ 247 * @return The error message, or NULL. 248 */ 241 249 const char *bithenge_scope_get_error(bithenge_scope_t *scope) 242 250 { … … 250 258 * @param scope The scope. 251 259 * @param format The format string. 252 * @return EINVAL normally, or another error code from errno.h. */ 260 * @return EINVAL normally, or another error code from errno.h. 261 */ 253 262 errno_t bithenge_scope_error(bithenge_scope_t *scope, const char *format, ...) 254 263 { … … 299 308 * @memberof bithenge_scope_t 300 309 * @param scope The scope to get the current node from. 301 * @return The node being created, or NULL. */ 310 * @return The node being created, or NULL. 311 */ 302 312 bithenge_node_t *bithenge_scope_get_current_node(bithenge_scope_t *scope) 303 313 { … … 310 320 * @memberof bithenge_scope_t 311 321 * @param scope The scope to set the current node in. 312 * @param node The current node being created, or NULL. */ 322 * @param node The current node being created, or NULL. 323 */ 313 324 void bithenge_scope_set_current_node(bithenge_scope_t *scope, 314 325 bithenge_node_t *node) … … 321 332 * @memberof bithenge_scope_t 322 333 * @param scope The scope to get the current input node from. 323 * @return The input node, or NULL. */ 334 * @return The input node, or NULL. 335 */ 324 336 bithenge_node_t *bithenge_scope_in_node(bithenge_scope_t *scope) 325 337 { … … 332 344 * @memberof bithenge_scope_t 333 345 * @param scope The scope to set the input node in. 334 * @param node The input node, or NULL. */ 346 * @param node The input node, or NULL. 347 */ 335 348 void bithenge_scope_set_in_node(bithenge_scope_t *scope, bithenge_node_t *node) 336 349 { … … 341 354 /** Set a scope as a barrier. 342 355 * @memberof bithenge_scope_t 343 * @param self The scope to change. */ 356 * @param self The scope to change. 357 */ 344 358 void bithenge_scope_set_barrier(bithenge_scope_t *self) 345 359 { … … 351 365 * @memberof bithenge_scope_t 352 366 * @param self The scope to check. 353 * @return Whether the scope is a barrier. */ 367 * @return Whether the scope is a barrier. 368 */ 354 369 bool bithenge_scope_is_barrier(bithenge_scope_t *self) 355 370 { … … 363 378 * @param scope The scope in which to allocate parameters. 364 379 * @param num_params The number of parameters to allocate. 365 * @return EOK on success or an error code from errno.h. */ 380 * @return EOK on success or an error code from errno.h. 381 */ 366 382 errno_t bithenge_scope_alloc_params(bithenge_scope_t *scope, int num_params) 367 383 { … … 381 397 * @param i The index of the parameter to set. 382 398 * @param node The value to store in the parameter. 383 * @return EOK on success or an error code from errno.h. */ 399 * @return EOK on success or an error code from errno.h. 400 */ 384 401 errno_t bithenge_scope_set_param(bithenge_scope_t *scope, int i, 385 402 bithenge_node_t *node) … … 400 417 * @param i The index of the parameter to set. 401 418 * @param[out] out Stores a new reference to the parameter. 402 * @return EOK on success or an error code from errno.h. */ 419 * @return EOK on success or an error code from errno.h. 420 */ 403 421 errno_t bithenge_scope_get_param(bithenge_scope_t *scope, int i, 404 422 bithenge_node_t **out) … … 502 520 * @param base The barrier transform. 503 521 * @param transform The subtransform to use for all operations. 504 * @return EOK on success or an error code from errno.h. */ 522 * @return EOK on success or an error code from errno.h. 523 */ 505 524 errno_t bithenge_barrier_transform_set_subtransform(bithenge_transform_t *base, 506 525 bithenge_transform_t *transform) … … 526 545 * @param[out] out Holds the created transform. 527 546 * @param num_params The number of parameters to require, which may be 0. 528 * @return EOK on success or an error code from errno.h. */ 547 * @return EOK on success or an error code from errno.h. 548 */ 529 549 errno_t bithenge_new_barrier_transform(bithenge_transform_t **out, int num_params) 530 550 { … … 742 762 743 763 /** A transform that converts a byte blob to a bit blob, most-significant bit 744 * first. */ 764 * first. 765 */ 745 766 bithenge_transform_t bithenge_bits_be_transform = { 746 767 &bits_xe_ops, 1, 0 … … 748 769 749 770 /** A transform that converts a byte blob to a bit blob, least-significant bit 750 * first. */ 771 * first. 772 */ 751 773 bithenge_transform_t bithenge_bits_le_transform = { 752 774 &bits_xe_ops, 1, 0 … … 987 1009 988 1010 /** A transform that reads an unsigned integer from an arbitrary number of 989 * bits, most-significant bit first. */ 1011 * bits, most-significant bit first. 1012 */ 990 1013 bithenge_transform_t bithenge_uint_be_transform = { 991 1014 &uint_xe_ops, 1, 1 … … 993 1016 994 1017 /** A transform that reads an unsigned integer from an arbitrary number of 995 * bits, least-significant bit first. */ 1018 * bits, least-significant bit first. 1019 */ 996 1020 bithenge_transform_t bithenge_uint_le_transform = { 997 1021 &uint_xe_ops, 1, 1 -
uspace/lib/bithenge/src/tree.c
rfac0ac7 r7c3fb9b 71 71 /** Decrement a node's reference count and free it if appropriate. 72 72 * @memberof bithenge_node_t 73 * @param node The node to dereference, or NULL. */ 73 * @param node The node to dereference, or NULL. 74 */ 74 75 void bithenge_node_dec_ref(bithenge_node_t *node) 75 76 { … … 112 113 * @param[out] out Holds the found node. 113 114 * @return EOK on success, ENOENT if not found, or another error code from 114 * errno.h. */ 115 * errno.h. 116 */ 115 117 errno_t bithenge_node_get(bithenge_node_t *self, bithenge_node_t *key, 116 118 bithenge_node_t **out) … … 154 156 * @param[out] self The node. 155 157 * @param[in] ops The operations provided. 156 * @return EOK on success or an error code from errno.h. */ 158 * @return EOK on success or an error code from errno.h. 159 */ 157 160 errno_t bithenge_init_internal_node(bithenge_node_t *self, 158 161 const bithenge_internal_node_ops_t *ops) … … 195 198 /** Create an empty internal node. 196 199 * @param[out] out Holds the created node. 197 * @return EOK on success or an error code from errno.h. */ 200 * @return EOK on success or an error code from errno.h. 201 */ 198 202 errno_t bithenge_new_empty_internal_node(bithenge_node_t **out) 199 203 { … … 262 266 * @param needs_free If true, when the internal node is destroyed it will free 263 267 * the nodes array rather than just dereferencing each node inside it. 264 * @return EOK on success or an error code from errno.h. */ 268 * @return EOK on success or an error code from errno.h. 269 */ 265 270 errno_t bithenge_new_simple_internal_node(bithenge_node_t **out, 266 271 bithenge_node_t **nodes, bithenge_int_t len, bool needs_free) … … 298 303 * @param[out] out Stores the created boolean node. 299 304 * @param value The value for the node to hold. 300 * @return EOK on success or an error code from errno.h. */ 305 * @return EOK on success or an error code from errno.h. 306 */ 301 307 errno_t bithenge_new_boolean_node(bithenge_node_t **out, bool value) 302 308 { … … 313 319 * @param[out] out Stores the created integer node. 314 320 * @param value The value for the node to hold. 315 * @return EOK on success or an error code from errno.h. */ 321 * @return EOK on success or an error code from errno.h. 322 */ 316 323 errno_t bithenge_new_integer_node(bithenge_node_t **out, bithenge_int_t value) 317 324 { … … 333 340 * @param needs_free Whether the string should be freed when the node is 334 341 * destroyed. 335 * @return EOK on success or an error code from errno.h. */ 342 * @return EOK on success or an error code from errno.h. 343 */ 336 344 errno_t bithenge_new_string_node(bithenge_node_t **out, const char *value, bool needs_free) 337 345 { … … 357 365 * @param a, b Nodes to compare. 358 366 * @return EOK on success or an error code from errno.h. 359 * @todo Add support for internal nodes. */ 367 * @todo Add support for internal nodes. 368 */ 360 369 errno_t bithenge_node_equal(bool *out, bithenge_node_t *a, bithenge_node_t *b) 361 370 {
Note:
See TracChangeset
for help on using the changeset viewer.