usr/src/lib/libumem/common/envvar.c
changeset 13708 6d0517b1a52b
parent 6812 febeba71273d
equal deleted inserted replaced
13707:3f41b24ce657 13708:6d0517b1a52b
    20  */
    20  */
    21 
    21 
    22 /*
    22 /*
    23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
    23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
    24  * Use is subject to license terms.
    24  * Use is subject to license terms.
       
    25  * Copyright 2012 Joyent, Inc. All rights reserved.
    25  */
    26  */
    26 
       
    27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
       
    28 
    27 
    29 #include <ctype.h>
    28 #include <ctype.h>
    30 #include <errno.h>
    29 #include <errno.h>
    31 #include <limits.h>
    30 #include <limits.h>
    32 #include <stdlib.h>
    31 #include <stdlib.h>
    82 	arg_process_t *item_special; /* callback for special handling */
    81 	arg_process_t *item_special; /* callback for special handling */
    83 } umem_env_item_t;
    82 } umem_env_item_t;
    84 
    83 
    85 #ifndef UMEM_STANDALONE
    84 #ifndef UMEM_STANDALONE
    86 static arg_process_t umem_backend_process;
    85 static arg_process_t umem_backend_process;
       
    86 static arg_process_t umem_allocator_process;
    87 #endif
    87 #endif
    88 
    88 
    89 static arg_process_t umem_log_process;
    89 static arg_process_t umem_log_process;
    90 
    90 
    91 static size_t umem_size_tempval;
    91 static size_t umem_size_tempval;
    97 #ifndef UMEM_STANDALONE
    97 #ifndef UMEM_STANDALONE
    98 	{ "backend",		"Evolving",	ITEM_SPECIAL,
    98 	{ "backend",		"Evolving",	ITEM_SPECIAL,
    99 		"=sbrk for sbrk(2), =mmap for mmap(2)",
    99 		"=sbrk for sbrk(2), =mmap for mmap(2)",
   100 		NULL, 0, NULL, NULL,
   100 		NULL, 0, NULL, NULL,
   101 		&umem_backend_process
   101 		&umem_backend_process
       
   102 	},
       
   103 	{ "allocator",		"Evolving",	ITEM_SPECIAL,
       
   104 		"=best, =first, =next, or =instant",
       
   105 		NULL, 0, NULL, NULL,
       
   106 		&umem_allocator_process
   102 	},
   107 	},
   103 #endif
   108 #endif
   104 
   109 
   105 	{ "concurrency",	"Private",	ITEM_UINT,
   110 	{ "concurrency",	"Private",	ITEM_UINT,
   106 		"Max concurrency",
   111 		"Max concurrency",
   470 
   475 
   471 fail:
   476 fail:
   472 	log_message("%s: %s: must be %s=sbrk or %s=mmap\n",
   477 	log_message("%s: %s: must be %s=sbrk or %s=mmap\n",
   473 	    CURRENT, name, name, name);
   478 	    CURRENT, name, name, name);
   474 	return (ARG_BAD);
   479 	return (ARG_BAD);
       
   480 }
       
   481 
       
   482 
       
   483 static int
       
   484 umem_allocator_process(const umem_env_item_t *item, const char *item_arg)
       
   485 {
       
   486 	const char *name = item->item_name;
       
   487 
       
   488 	if (item_arg == NULL)
       
   489 		goto fail;
       
   490 
       
   491 	if (strcmp(item_arg, "best") == 0)
       
   492 		vmem_allocator = VM_BESTFIT;
       
   493 	else if (strcmp(item_arg, "next") == 0)
       
   494 		vmem_allocator = VM_NEXTFIT;
       
   495 	else if (strcmp(item_arg, "first") == 0)
       
   496 		vmem_allocator = VM_FIRSTFIT;
       
   497 	else if (strcmp(item_arg, "instant") == 0)
       
   498 		vmem_allocator = 0;
       
   499 	else
       
   500 		goto fail;
       
   501 
       
   502 	return (ARG_SUCCESS);
       
   503 
       
   504 fail:
       
   505 	log_message("%s: %s: must be %s=best, %s=next or %s=first\n",
       
   506 	    CURRENT, name, name, name, name);
       
   507 	return (ARG_BAD);
       
   508 
   475 }
   509 }
   476 #endif
   510 #endif
   477 
   511 
   478 static int
   512 static int
   479 process_item(const umem_env_item_t *item, const char *item_arg)
   513 process_item(const umem_env_item_t *item, const char *item_arg)