kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
/* Copyright 2009, 2010 The University of Texas at Austin.           */
kusano 2b45e8
/* All rights reserved.                                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* Redistribution and use in source and binary forms, with or        */
kusano 2b45e8
/* without modification, are permitted provided that the following   */
kusano 2b45e8
/* conditions are met:                                               */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   1. Redistributions of source code must retain the above         */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer.                                                  */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   2. Redistributions in binary form must reproduce the above      */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer in the documentation and/or other materials       */
kusano 2b45e8
/*      provided with the distribution.                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
kusano 2b45e8
/*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
kusano 2b45e8
/*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
kusano 2b45e8
/*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
kusano 2b45e8
/*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
kusano 2b45e8
/*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
kusano 2b45e8
/*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
kusano 2b45e8
/*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
kusano 2b45e8
/*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
kusano 2b45e8
/*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
kusano 2b45e8
/*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
kusano 2b45e8
/*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
kusano 2b45e8
/*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
kusano 2b45e8
/*    POSSIBILITY OF SUCH DAMAGE.                                    */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* The views and conclusions contained in the software and           */
kusano 2b45e8
/* documentation are those of the authors and should not be          */
kusano 2b45e8
/* interpreted as representing official policies, either expressed   */
kusano 2b45e8
/* or implied, of The University of Texas at Austin.                 */
kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
kusano 2b45e8
#ifndef COMMON_LINUX_H
kusano 2b45e8
#define COMMON_LINUX_H
kusano 2b45e8
kusano 2b45e8
#ifndef ASSEMBLER
kusano 2b45e8
kusano 2b45e8
#include <syscall.h></syscall.h>
kusano 2b45e8
kusano 2b45e8
extern long int syscall (long int __sysno, ...);
kusano 2b45e8
kusano 2b45e8
#ifndef MPOL_PREFERRED
kusano 2b45e8
#define MPOL_PREFERRED 1
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef MPOL_INTERLEAVE
kusano 2b45e8
#define MPOL_INTERLEAVE 3
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(ARCH_IA64) && defined(__ECC)
kusano 2b45e8
#ifndef __NR_mbind
kusano 2b45e8
#define __NR_mbind			1259
kusano 2b45e8
#endif
kusano 2b45e8
#ifndef __NR_get_mempolicy
kusano 2b45e8
#define __NR_get_mempolicy		1260
kusano 2b45e8
#endif
kusano 2b45e8
#ifndef __NR_set_mempolicy
kusano 2b45e8
#define __NR_set_mempolicy		1261
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
static inline int my_mbind(void *addr, unsigned long len, int mode,
kusano 2b45e8
			   unsigned long *nodemask, unsigned long maxnode,
kusano 2b45e8
			   unsigned flags) {
kusano 2b45e8
#if defined (LOONGSON3B) 
kusano 2b45e8
#if defined (__64BIT__)
kusano 2b45e8
	return syscall(SYS_mbind, addr, len, mode, nodemask, maxnode, flags);
kusano 2b45e8
#else
kusano 2b45e8
	return 0; //NULL Implementation on Loongson 3B 32bit.
kusano 2b45e8
#endif
kusano 2b45e8
#else
kusano 2b45e8
//Fixed randomly SEGFAULT when nodemask==NULL with above Linux 2.6.34
kusano 2b45e8
//	unsigned long null_nodemask=0;
kusano 2b45e8
	return syscall(SYS_mbind, addr, len, mode, nodemask, maxnode, flags);
kusano 2b45e8
#endif
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
static inline int my_set_mempolicy(int mode, const unsigned long *addr, unsigned long flag) {
kusano 2b45e8
kusano 2b45e8
  return syscall(SYS_set_mempolicy, mode, addr, flag);
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
static inline int my_gettid(void) { return syscall(SYS_gettid); }
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
#endif