Created
May 5, 2012 21:53
-
-
Save nolta/2605833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test to understand what https://gist.github.com/2517475 is actually doing. | |
#include <stdio.h> | |
#define __AC(X,Y) (X##Y) | |
#define _AC(X,Y) __AC(X,Y) | |
#define BITS_PER_BYTE 8 | |
#define PAGE_SHIFT 12 | |
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) | |
#define __user | |
#define EINVAL 22 /* Invalid argument */ | |
// extracted from <linux-kernel>/mm/mempolicy.c | |
static int get_nodes(const unsigned long __user *nmask, | |
unsigned long maxnode) | |
{ | |
--maxnode; | |
if (maxnode == 0 || !nmask) | |
return 0; | |
if (maxnode > PAGE_SIZE*BITS_PER_BYTE) | |
return -EINVAL; | |
} | |
int | |
main(int argc, char *argv[]) | |
{ | |
unsigned long null_nodemask=0, maxnode=0; | |
printf("get_nodes(NULL,0) = %d\n", get_nodes(NULL,maxnode)); | |
printf("get_nodes(&null_nodemask,0) = %d\n", get_nodes(&null_nodemask,maxnode)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment