1 // $Id: cflags-compat.c,v 1.1 2004/04/14 23:19:51 ensc Exp $ --*- c -*--
3 // Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
30 char const * const id;
33 } const FLAGVALUES[] = {
34 DECL("lock", S_CTX_INFO_LOCK),
35 DECL("sched", S_CTX_INFO_SCHED),
36 DECL("nproc", S_CTX_INFO_NPROC),
37 DECL("private", S_CTX_INFO_PRIVATE),
38 DECL("fakeinit", S_CTX_INFO_INIT),
39 DECL("hideinfo", S_CTX_INFO_HIDEINFO),
40 DECL("ulimit", S_CTX_INFO_ULIMIT),
41 DECL("namespace", S_CTX_INFO_NAMESPACE),
45 vc_text2cflag_compat(char const *str, size_t len)
48 if (len==0) len=strlen(str);
50 for (i=0; i<sizeof(FLAGVALUES)/sizeof(FLAGVALUES[0]); ++i)
51 if (len==FLAGVALUES[i].len &&
52 strncmp(FLAGVALUES[i].id, str, len)==0)
53 return FLAGVALUES[i].val;
59 vc_hicflag2text_compat(uint_least32_t val)
64 assert(S_CTX_INFO_ULIMIT==64);
66 for (i=S_CTX_INFO_ULIMIT, idx=6; i>0; i/=2, --idx)
67 if (val & i) return FLAGVALUES[idx].id;