Пример #1
0
		break;
	case MESSAGE_DEACTIVATE_LAYOUT:
		if (state.len != 1) {
			state.status = MESSAGE_ERROR;
			return;
		}
		LAYOUT_deactivate();
		break;
	default:
		state.status = WRONG_MESSAGE_ERROR;
		return;
	};
	state.status = IDLE;
}

void RAWHID_PROTOCOL_handle_packet(uint8_t __attribute__((unused)) flags)
{
	struct RAWHID_packet buf;
	if (!RAWHID_recv(&buf))
		return;
	switch (buf.header) {
	case MSG_START: {
		if (state.status == EXECUTING) {
			state.status = BUSY_ERROR;
			break;
		} else if (state.status != IDLE) {
			break;
		}
		state.len = buf.payload[0];
		state.crc = *(uint16_t*)&buf.payload[1];
		const int to_copy = min(RAWHID_SIZE - MSG_HDR_SIZE - 1, state.len);
Пример #2
0
#include <assert.h>
#include <error.h>
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>

#include <libasmP.h>
#include <libelf.h>
#include <system.h>


static int
text_end (AsmCtx_t *ctx __attribute__ ((unused)))
{
  if (fclose (ctx->out.file) != 0)
    {
      __libasm_seterrno (ASM_E_IOERROR);
      return -1;
    }

  return 0;
}


static int
binary_end (AsmCtx_t *ctx)
{
  void *symtab = NULL;
  (*env)->ReleaseIntArrayElements (env, jpixels, java_pixels, 0);

  (*env)->CallVoidMethod (env, 
			  *decoder, 
			  areaUpdatedID,
			  (jint) x, (jint) y,
			  (jint) width, (jint) height,
			  jpixels,
			  stride_pixels);

  (*env)->DeleteLocalRef(env, jpixels);
}

static void
closed_cb (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder)
{
  JNIEnv *env;
  union env_union e;
  e.jni_env = &env;
  (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1);

  (*env)->DeleteGlobalRef (env, *decoder); 
  g_free (decoder);
}



JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initState
  (JNIEnv *env, jobject obj)
Пример #4
0
int main(int argc, char **argv) {

	int fd;
    int rv;
    char buf[4096] __attribute__ ((aligned));
	period--; // counter starts at 0

	if (argc > 1)
		cache = 1;

	if(getuid() != 0) {
        fail("Only root can use me.");
    }

	/* make stdin non-blocking, i.e. optional */
	int flags = fcntl(0, F_GETFL, 0);
	flags |= O_NONBLOCK;
	fcntl(0, F_SETFL, flags);


	/* close nfq hooks on exit */
	if(signal(SIGINT, sig_handler) == SIG_IGN)
        signal(SIGINT, SIG_IGN);
    if(signal(SIGHUP, sig_handler) == SIG_IGN)
        signal(SIGINT, SIG_IGN);
    if(signal(SIGTERM, sig_handler) == SIG_IGN)
        signal(SIGINT, SIG_IGN);


	/* hook callback() into userspace netlink queue */
	if (!(nfqh = nfq_open()))
		fail("nfq_open() failed");

	if (0 > nfq_unbind_pf(nfqh, AF_INET))
		fail("nfq_unbind_pf failed");

	if (0 > nfq_bind_pf(nfqh, AF_INET))
		fail("nfq_bind_pf failed");

	if (!(qh = nfq_create_queue(nfqh, 0, &callback, NULL)))
		fail("nfq_create_queue failed");

	if (0 > nfq_set_mode(qh, NFQNL_COPY_META, 0xffff))
		fail("nfq_set_mode failed");


	nh = nfq_nfnlh(nfqh);
	fd = nfnl_fd(nh);

	printf("Commencing packet mangling..\n");

	clock_gettime(CLOCK_REALTIME, &last_time);

	while ((rv = recv(fd, buf, sizeof(buf), 0)) && rv >= 0)
		nfq_handle_packet(nfqh, buf, rv);


    printf("exiting..\n");

    return 0;
}
Пример #5
0
static int async_encrypt(struct ablkcipher_request *req)
{
	struct crypto_tfm *tfm = req->base.tfm;
	struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
	struct blkcipher_desc desc = {
		.tfm = __crypto_blkcipher_cast(tfm),
		.info = req->info,
		.flags = req->base.flags,
	};


	return alg->encrypt(&desc, req->dst, req->src, req->nbytes);
}

static int async_decrypt(struct ablkcipher_request *req)
{
	struct crypto_tfm *tfm = req->base.tfm;
	struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
	struct blkcipher_desc desc = {
		.tfm = __crypto_blkcipher_cast(tfm),
		.info = req->info,
		.flags = req->base.flags,
	};

	return alg->decrypt(&desc, req->dst, req->src, req->nbytes);
}

static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,
					     u32 mask)
{
	struct blkcipher_alg *cipher = &alg->cra_blkcipher;
	unsigned int len = alg->cra_ctxsize;

	if ((mask & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_MASK &&
	    cipher->ivsize) {
		len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
		len += cipher->ivsize;
	}

	return len;
}

static int crypto_init_blkcipher_ops_async(struct crypto_tfm *tfm)
{
	struct ablkcipher_tfm *crt = &tfm->crt_ablkcipher;
	struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;

	crt->setkey = async_setkey;
	crt->encrypt = async_encrypt;
	crt->decrypt = async_decrypt;
	if (!alg->ivsize) {
		crt->givencrypt = skcipher_null_givencrypt;
		crt->givdecrypt = skcipher_null_givdecrypt;
	}
	crt->base = __crypto_ablkcipher_cast(tfm);
	crt->ivsize = alg->ivsize;

	return 0;
}

static int crypto_init_blkcipher_ops_sync(struct crypto_tfm *tfm)
{
	struct blkcipher_tfm *crt = &tfm->crt_blkcipher;
	struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
	unsigned long align = crypto_tfm_alg_alignmask(tfm) + 1;
	unsigned long addr;

	crt->setkey = setkey;
	crt->encrypt = alg->encrypt;
	crt->decrypt = alg->decrypt;

	addr = (unsigned long)crypto_tfm_ctx(tfm);
	addr = ALIGN(addr, align);
	addr += ALIGN(tfm->__crt_alg->cra_ctxsize, align);
	crt->iv = (void *)addr;

	return 0;
}

static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
{
	struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;

	if (alg->ivsize > PAGE_SIZE / 8)
		return -EINVAL;

	if ((mask & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_MASK)
		return crypto_init_blkcipher_ops_sync(tfm);
	else
		return crypto_init_blkcipher_ops_async(tfm);
}

static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
	__attribute__ ((unused));
static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
{
	seq_printf(m, "type         : blkcipher\n");
	seq_printf(m, "blocksize    : %u\n", alg->cra_blocksize);
	seq_printf(m, "min keysize  : %u\n", alg->cra_blkcipher.min_keysize);
	seq_printf(m, "max keysize  : %u\n", alg->cra_blkcipher.max_keysize);
	seq_printf(m, "ivsize       : %u\n", alg->cra_blkcipher.ivsize);
	seq_printf(m, "geniv        : %s\n", alg->cra_blkcipher.geniv ?:
					     "<default>");
}

const struct crypto_type crypto_blkcipher_type = {
	.ctxsize = crypto_blkcipher_ctxsize,
	.init = crypto_init_blkcipher_ops,
#ifdef CONFIG_PROC_FS
	.show = crypto_blkcipher_show,
#endif
};
EXPORT_SYMBOL_GPL(crypto_blkcipher_type);

static int crypto_grab_nivcipher(struct crypto_skcipher_spawn *spawn,
				const char *name, u32 type, u32 mask)
{
	struct crypto_alg *alg;
	int err;

	type = crypto_skcipher_type(type);
	mask = crypto_skcipher_mask(mask)| CRYPTO_ALG_GENIV;

	alg = crypto_alg_mod_lookup(name, type, mask);
	if (IS_ERR(alg))
		return PTR_ERR(alg);

	err = crypto_init_spawn(&spawn->base, alg, spawn->base.inst, mask);
	crypto_mod_put(alg);
	return err;
}

struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl,
					     struct rtattr **tb, u32 type,
					     u32 mask)
{
	struct {
		int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key,
			      unsigned int keylen);
		int (*encrypt)(struct ablkcipher_request *req);
		int (*decrypt)(struct ablkcipher_request *req);

		unsigned int min_keysize;
		unsigned int max_keysize;
		unsigned int ivsize;

		const char *geniv;
	} balg;
	const char *name;
	struct crypto_skcipher_spawn *spawn;
	struct crypto_attr_type *algt;
	struct crypto_instance *inst;
	struct crypto_alg *alg;
	int err;

	algt = crypto_get_attr_type(tb);
	err = PTR_ERR(algt);
	if (IS_ERR(algt))
		return ERR_PTR(err);

	if ((algt->type ^ (CRYPTO_ALG_TYPE_GIVCIPHER | CRYPTO_ALG_GENIV)) &
	    algt->mask)
		return ERR_PTR(-EINVAL);

	name = crypto_attr_alg_name(tb[1]);
	err = PTR_ERR(name);
	if (IS_ERR(name))
		return ERR_PTR(err);

	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
	if (!inst)
		return ERR_PTR(-ENOMEM);

	spawn = crypto_instance_ctx(inst);

	/* Ignore async algorithms if necessary. */
	mask |= crypto_requires_sync(algt->type, algt->mask);

	crypto_set_skcipher_spawn(spawn, inst);
	err = crypto_grab_nivcipher(spawn, name, type, mask);
	if (err)
		goto err_free_inst;

	alg = crypto_skcipher_spawn_alg(spawn);

	if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
	    CRYPTO_ALG_TYPE_BLKCIPHER) {
		balg.ivsize = alg->cra_blkcipher.ivsize;
		balg.min_keysize = alg->cra_blkcipher.min_keysize;
		balg.max_keysize = alg->cra_blkcipher.max_keysize;

		balg.setkey = async_setkey;
		balg.encrypt = async_encrypt;
		balg.decrypt = async_decrypt;

		balg.geniv = alg->cra_blkcipher.geniv;
	} else {
		balg.ivsize = alg->cra_ablkcipher.ivsize;
		balg.min_keysize = alg->cra_ablkcipher.min_keysize;
		balg.max_keysize = alg->cra_ablkcipher.max_keysize;

		balg.setkey = alg->cra_ablkcipher.setkey;
		balg.encrypt = alg->cra_ablkcipher.encrypt;
		balg.decrypt = alg->cra_ablkcipher.decrypt;

		balg.geniv = alg->cra_ablkcipher.geniv;
	}

	err = -EINVAL;
	if (!balg.ivsize)
		goto err_drop_alg;

	/*
	 * This is only true if we're constructing an algorithm with its
	 * default IV generator.  For the default generator we elide the
	 * template name and double-check the IV generator.
	 */
	if (algt->mask & CRYPTO_ALG_GENIV) {
		if (!balg.geniv)
			balg.geniv = crypto_default_geniv(alg);
		err = -EAGAIN;
		if (strcmp(tmpl->name, balg.geniv))
			goto err_drop_alg;

		memcpy(inst->alg.cra_name, alg->cra_name, CRYPTO_MAX_ALG_NAME);
		memcpy(inst->alg.cra_driver_name, alg->cra_driver_name,
		       CRYPTO_MAX_ALG_NAME);
	} else {
		err = -ENAMETOOLONG;
		if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME,
			     "%s(%s)", tmpl->name, alg->cra_name) >=
		    CRYPTO_MAX_ALG_NAME)
			goto err_drop_alg;
		if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
			     "%s(%s)", tmpl->name, alg->cra_driver_name) >=
		    CRYPTO_MAX_ALG_NAME)
			goto err_drop_alg;
	}

	inst->alg.cra_flags = CRYPTO_ALG_TYPE_GIVCIPHER | CRYPTO_ALG_GENIV;
	inst->alg.cra_flags |= alg->cra_flags & CRYPTO_ALG_ASYNC;
	inst->alg.cra_priority = alg->cra_priority;
	inst->alg.cra_blocksize = alg->cra_blocksize;
	inst->alg.cra_alignmask = alg->cra_alignmask;
	inst->alg.cra_type = &crypto_givcipher_type;

	inst->alg.cra_ablkcipher.ivsize = balg.ivsize;
	inst->alg.cra_ablkcipher.min_keysize = balg.min_keysize;
	inst->alg.cra_ablkcipher.max_keysize = balg.max_keysize;
	inst->alg.cra_ablkcipher.geniv = balg.geniv;

	inst->alg.cra_ablkcipher.setkey = balg.setkey;
	inst->alg.cra_ablkcipher.encrypt = balg.encrypt;
	inst->alg.cra_ablkcipher.decrypt = balg.decrypt;

out:
	return inst;

err_drop_alg:
	crypto_drop_skcipher(spawn);
err_free_inst:
	kfree(inst);
	inst = ERR_PTR(err);
	goto out;
}
EXPORT_SYMBOL_GPL(skcipher_geniv_alloc);

void skcipher_geniv_free(struct crypto_instance *inst)
{
	crypto_drop_skcipher(crypto_instance_ctx(inst));
	kfree(inst);
}
Пример #6
0
   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library.  If not, see
   <http://www.gnu.org/licenses/>.  */

#define HAVE_ARCH_PLTENTER
#define HAVE_ARCH_PLTEXIT

#include <elf/sotruss-lib.c>

ElfW(Addr)
la_m68k_gnu_pltenter (Elf32_Sym *sym __attribute__ ((unused)),
		      unsigned int ndx __attribute__ ((unused)),
		      uintptr_t *refcook, uintptr_t *defcook,
		      La_m68k_regs *regs, unsigned int *flags,
		      const char *symname, long int *framesizep)
{
  unsigned long int *sp = (unsigned long int *) regs->lr_sp;

  print_enter (refcook, defcook, symname, sp[1], sp[2], sp[3], *flags);

  /* No need to copy anything, we will not need the parameters in any case.  */
  *framesizep = 0;

  return sym->st_value;
}
Пример #7
0
#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <pthread.h>

#include <errno.h>
#include <rtems/seterr.h>

/**
 *  POSIX 1003.1b 3.1.3
 *
 *  3.1.3 Register Fork Handlers, P1003.1c/Draft 10, P1003.1c/Draft 10, p. 27
 *
 *  RTEMS does not support processes, so we fall under this and do not
 *  provide this routine:
 *
 *  "Either the implementation shall support the pthread_atfork() function
 *   as described above or the pthread_atfork() funciton shall not be
 *   provided."
 */
int pthread_atfork(
  void (*prepare)(void) __attribute__((unused)),
  void (*parent)(void) __attribute__((unused)),
  void (*child)(void) __attribute__((unused))
)
{
  rtems_set_errno_and_return_minus_one( ENOSYS );
}
Пример #8
0
} iter_t;

static int
maybe_emit_host(iter_t *iter, sdb_memstore_obj_t *obj)
{
	if ((obj->type == SDB_HOST) || (obj->type == SDB_ATTRIBUTE))
		return 0;
	if (iter->current_host == obj->parent)
		return 0;
	iter->current_host = obj->parent;
	return sdb_memstore_emit(obj->parent, iter->w, iter->wd);
} /* maybe_emit_host */

static int
list_tojson(sdb_memstore_obj_t *obj,
		sdb_memstore_matcher_t __attribute__((unused)) *filter,
		void *user_data)
{
	iter_t *iter = user_data;
	maybe_emit_host(iter, obj);
	return sdb_memstore_emit(obj, iter->w, iter->wd);
} /* list_tojson */

static int
lookup_tojson(sdb_memstore_obj_t *obj, sdb_memstore_matcher_t *filter,
		void *user_data)
{
	iter_t *iter = user_data;
	maybe_emit_host(iter, obj);
	return sdb_memstore_emit_full(obj, filter, iter->w, iter->wd);
} /* lookup_tojson */
Пример #9
0
struct aio_msg_ {
   queue_link_t link ;
   size_t size ;
   u_int8_t *msg ;
};
#line 50 "aio_simple.h"
typedef struct aio_msg_ aio_msg_t;
#line 1 "cil-GU0xBf_3.o"
#pragma merger("0","/tmp/cil-FeO61O71.i","-Wall,-Werror,-g")
#line 364 "/usr/include/stdio.h"
extern  __attribute__((__nothrow__)) int sprintf(char * __restrict  __s , char const   * __restrict  __format 
                                                 , ...) ;
#line 846
extern void perror(char const   *__s ) ;
#line 395 "/usr/include/string.h"
extern  __attribute__((__nothrow__)) size_t ( __attribute__((__nonnull__(1), __leaf__)) strlen)(char const   *__s )  __attribute__((__pure__)) ;
#line 455
extern  __attribute__((__nothrow__)) void ( __attribute__((__nonnull__(1), __leaf__)) bzero)(void *__s ,
                                                                                             size_t __n ) ;
#line 465 "/usr/include/stdlib.h"
extern  __attribute__((__nothrow__)) void *( __attribute__((__leaf__)) malloc)(size_t __size )  __attribute__((__malloc__)) ;
#line 482
extern  __attribute__((__nothrow__)) void ( __attribute__((__leaf__)) free)(void *__ptr ) ;
#line 542
extern  __attribute__((__nothrow__, __noreturn__)) void ( __attribute__((__leaf__)) exit)(int __status ) ;
#line 366 "/usr/include/unistd.h"
extern ssize_t write(int __fd , void const   *__buf , size_t __n ) ;
#line 444
extern unsigned int sleep(unsigned int __seconds ) ;
#line 232 "/usr/include/pthread.h"
extern  __attribute__((__nothrow__)) int ( __attribute__((__nonnull__(1,3))) pthread_create)(pthread_t * __restrict  __newthread ,
Пример #10
0
    case (EXPRESSION_TYPE_OPERATOR_CONCAT):
      throw ExpressionException("Concat operator not yet supported.");

    case (EXPRESSION_TYPE_OPERATOR_CAST):
      throw ExpressionException("Cast operator not yet supported.");

    default:
      throw ExpressionException("operator ctor helper out of sync");
  }
  return ret;
}

// convert the enumerated value type into a concrete c type for
// constant value expressions templated ctors
AbstractExpression *ConstantValueFactory(
    json_spirit::Object &obj, __attribute__((unused)) ValueType vt,
    __attribute__((unused)) ExpressionType et,
    __attribute__((unused)) AbstractExpression *lc,
    __attribute__((unused)) AbstractExpression *rc) {
  // read before ctor - can then instantiate fully init'd obj.
  Value newvalue;
  json_spirit::Value valueValue = json_spirit::find_value(obj, "VALUE");
  if (valueValue == json_spirit::Value::null) {
    throw ExpressionException(
        "constantValueFactory: Could not find"
        " VALUE value");
  }

  if (valueValue.type() == json_spirit::str_type) {
    std::string nullcheck = valueValue.get_str();
    if (nullcheck == "nullptr") {
Пример #11
0
  if(dberror_del == 0){
    if(pctldb->mf_total_size > mf->size)
      pctldb->mf_total_size -= mf->size;
    else
      pctldb->mf_total_size = 0;
  }else{
    if(*dberror == 0){
      status = -1;
      *dberror = dberror_del;
    }
  }

  return(status);
}

static int timespec_cmp(DB *dbp __attribute__((unused)),
			const DBT *a, const DBT *b){

  struct timespec ts1, ts2;
  int size;

  size = sizeof(struct timespec);
  memcpy(&ts1, a->data, size);
  memcpy(&ts2, b->data, size);

  if(ts1.tv_sec != ts2.tv_sec)
    return(ts1.tv_sec < ts2.tv_sec ? -1 : 1);

  if(ts1.tv_nsec != ts2.tv_nsec)
    return(ts1.tv_nsec < ts2.tv_nsec ? -1 : 1);
Пример #12
0
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */

/* Open a temporary file and cache it with io_cache. Delete it on close */

#include "mysys_priv.h"
#include <m_string.h>
#include "my_static.h"
#include "mysys_err.h"

	/*
	  Remove an open tempfile so that it doesn't survive
	  if we crash;	If the operating system doesn't support
	  this, just remember the file name for later removal
	*/

static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)),
				     const char *name)
{
#if O_TEMPORARY == 0
#if !defined(CANT_DELETE_OPEN_FILES)
  /* The following should always succeed */
  (void) my_delete(name,MYF(MY_WME | ME_NOINPUT));
#else
  int length;
  if (!(cache->file_name=
	(char*) my_malloc((length=strlen(name)+1),MYF(MY_WME))))
  {
    my_close(cache->file,MYF(0));
    cache->file = -1;
    errno=my_errno=ENOMEM;
    return 1;
Пример #13
0
/**
 * Convert EFI image to ROM image
 *
 * @v pe		EFI file
 * @v rom		ROM file
 */
static void make_efi_rom ( FILE *pe, FILE *rom, struct options *opts ) {
	struct {
		EFI_PCI_EXPANSION_ROM_HEADER rom;
		PCI_DATA_STRUCTURE pci __attribute__ (( aligned ( 4 ) ));
		uint8_t checksum;
	} *headers;
	struct stat pe_stat;
	size_t pe_size;
	size_t rom_size;
	void *buf;
	void *payload;
	unsigned int i;
	uint8_t checksum;

	/* Determine PE file size */
	if ( fstat ( fileno ( pe ), &pe_stat ) != 0 ) {
		eprintf ( "Could not stat PE file: %s\n",
			  strerror ( errno ) );
		exit ( 1 );
	}
	pe_size = pe_stat.st_size;

	/* Determine ROM file size */
	rom_size = ( ( pe_size + sizeof ( *headers ) + 511 ) & ~511 );

	/* Allocate ROM buffer and read in PE file */
	buf = xmalloc ( rom_size );
	memset ( buf, 0, rom_size );
	headers = buf;
	payload = ( buf + sizeof ( *headers ) );
	if ( fread ( payload, pe_size, 1, pe ) != 1 ) {
		eprintf ( "Could not read PE file: %s\n",
			  strerror ( errno ) );
		exit ( 1 );
	}

	/* Construct ROM header */
	headers->rom.Signature = PCI_EXPANSION_ROM_HEADER_SIGNATURE;
	headers->rom.InitializationSize = ( rom_size / 512 );
	headers->rom.EfiSignature = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE;
	read_pe_info ( payload, &headers->rom.EfiMachineType,
		       &headers->rom.EfiSubsystem );
	headers->rom.EfiImageHeaderOffset = sizeof ( *headers );
	headers->rom.PcirOffset =
		offsetof ( typeof ( *headers ), pci );
	headers->pci.Signature = PCI_DATA_STRUCTURE_SIGNATURE;
	headers->pci.VendorId = opts->vendor;
	headers->pci.DeviceId = opts->device;
	headers->pci.Length = sizeof ( headers->pci );
	headers->pci.ClassCode[2] = PCI_CLASS_NETWORK;
	headers->pci.ImageLength = ( rom_size / 512 );
	headers->pci.CodeType = 0x03; /* No constant in EFI headers? */
	headers->pci.Indicator = 0x80; /* No constant in EFI headers? */

	/* Fix image checksum */
	for ( i = 0, checksum = 0 ; i < rom_size ; i++ )
		checksum += *( ( uint8_t * ) buf + i );
	headers->checksum -= checksum;

	/* Write out ROM */
	if ( fwrite ( buf, rom_size, 1, rom ) != 1 ) {
		eprintf ( "Could not write ROM file: %s\n",
			  strerror ( errno ) );
		exit ( 1 );
	}
}
Пример #14
0
	g_return_val_if_fail(method_name != NULL, NULL);
	/* 'args' may be NULL if not supplied. */

	libntfs_gnomevfs_method_ptr = libntfs_gnomevfs_method_init(method_name,
			args);

	g_atexit(vfs_module_shutdown_atexit);

	return libntfs_gnomevfs_method_ptr;
}

/**
 * vfs_module_shutdown:
 */
void vfs_module_shutdown(GnomeVFSMethod *method __attribute__((unused)))
{
	/*
	 * 'method' may be NULL if we are called from
	 *  vfs_module_shutdown_atexit().
	 */

	libntfs_gnomevfs_method_shutdown();
}

static void vfs_module_shutdown_atexit(void)
{
	vfs_module_shutdown(NULL);
}

Пример #15
0
int scanhash_chain(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
	uint32_t max_nonce, unsigned long *hashes_done)
{        
 uint32_t n = pdata[19] - 1;
        const uint32_t first_nonce = pdata[19];
        const uint32_t Htarg = ptarget[7];

        uint32_t hash64[8] __attribute__((aligned(32)));
        uint32_t endiandata[32];
        
        
        int kk=0;
        for (; kk < 32; kk++)
        {
                be32enc(&endiandata[kk], ((uint32_t*)pdata)[kk]);
        };


        if (ptarget[7]==0) {
                do {
                        pdata[19] = ++n;
                        be32enc(&endiandata[19], n);
                        chainhash(hash64, &endiandata);
                        if (((hash64[7]&0xFFFFFFFF)==0) &&
                                        fulltest(hash64, ptarget)) {
                                *hashes_done = n - first_nonce + 1;
                                return true;
                        }
                } while (n < max_nonce && !work_restart[thr_id].restart);
        }
        else if (ptarget[7]<=0xF)
        {
                do {
                        pdata[19] = ++n;
                        be32enc(&endiandata[19], n);
                        chainhash(hash64, &endiandata);
                        if (((hash64[7]&0xFFFFFFF0)==0) &&
                                        fulltest(hash64, ptarget)) {
                                *hashes_done = n - first_nonce + 1;
                                return true;
                        }
                } while (n < max_nonce && !work_restart[thr_id].restart);
        }
        else if (ptarget[7]<=0xFF)
        {
                do {
                        pdata[19] = ++n;
                        be32enc(&endiandata[19], n);
                        chainhash(hash64, &endiandata);
                        if (((hash64[7]&0xFFFFFF00)==0) &&
                                        fulltest(hash64, ptarget)) {
                                *hashes_done = n - first_nonce + 1;
                                return true;
                        }
                } while (n < max_nonce && !work_restart[thr_id].restart);
        }
        else if (ptarget[7]<=0xFFF)
        {
                do {
                        pdata[19] = ++n;
                        be32enc(&endiandata[19], n);
                        chainhash(hash64, &endiandata);
                        if (((hash64[7]&0xFFFFF000)==0) &&
                                        fulltest(hash64, ptarget)) {
                                *hashes_done = n - first_nonce + 1;
                                return true;
                        }
                } while (n < max_nonce && !work_restart[thr_id].restart);

        }
        else if (ptarget[7]<=0xFFFF)
        {
                do {
                        pdata[19] = ++n;
                        be32enc(&endiandata[19], n);
                        chainhash(hash64, &endiandata);
                        if (((hash64[7]&0xFFFF0000)==0) &&
                                        fulltest(hash64, ptarget)) {
                                *hashes_done = n - first_nonce + 1;
                                return true;
                        }
                } while (n < max_nonce && !work_restart[thr_id].restart);

        }
        else
        {
                do {
                        pdata[19] = ++n;
                        be32enc(&endiandata[19], n);
                        chainhash(hash64, &endiandata);
                        if (fulltest(hash64, ptarget)) {
                                *hashes_done = n - first_nonce + 1;
                                return true;
                        }
                } while (n < max_nonce && !work_restart[thr_id].restart);
        }
        
        
        *hashes_done = n - first_nonce + 1;
        pdata[19] = n;
        return 0;
}
Пример #16
0
#include <ctype.h>
#include "conf.h"
#include "msg.h"
#include "syslogd-types.h"
#include "template.h"
#include "module-template.h"
#include "errmsg.h"
#include "cfsysline.h"
#include "unicode-helper.h"
#include "dirty.h"

MODULE_TYPE_OUTPUT
MODULE_TYPE_NOKEEP
MODULE_CNFNAME("mmsnmptrapd")

static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal);

/* static data */

/* internal structures
 */
DEF_OMOD_STATIC_DATA

struct severMap_s {
	uchar *name;
	int code;
	struct severMap_s *next;
};

typedef struct _instanceData {
	uchar *pszTagName;
void
my_com_netsplit_Nih_Test_property_get_notify (DBusPendingCall *   pending_call,
                                              NihDBusPendingData *pending_data)
{
	DBusMessage *   reply;
	DBusMessageIter iter;
	DBusMessageIter variter;
	NihDBusMessage *message;
	DBusError       error;
	const char *    value_dbus;
	char *          value;

	nih_assert (pending_call != NULL);
	nih_assert (pending_data != NULL);

	nih_assert (dbus_pending_call_get_completed (pending_call));

	/* Steal the reply from the pending call. */
	reply = dbus_pending_call_steal_reply (pending_call);
	nih_assert (reply != NULL);

	/* Handle error replies */
	if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
		message = NIH_MUST (nih_dbus_message_new (pending_data, pending_data->connection, reply));

		dbus_error_init (&error);
		dbus_set_error_from_message (&error, message->message);

		nih_error_push_context ();
		nih_dbus_error_raise (error.name, error.message);
		pending_data->error_handler (pending_data->data, message);
		nih_error_pop_context ();

		dbus_error_free (&error);
		nih_free (message);
		dbus_message_unref (reply);
		return;
	}

	nih_assert (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN);

	do {
		__label__ enomem;

		/* Create a message context for the reply, and iterate
		 * over and recurse into the arguments.
		 */
		message = nih_dbus_message_new (pending_data, pending_data->connection, reply);
		if (! message)
			goto enomem;

		dbus_message_iter_init (message->message, &iter);

		if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_VARIANT) {
			nih_error_push_context ();
			nih_error_raise (NIH_DBUS_INVALID_ARGS,
			                 _(NIH_DBUS_INVALID_ARGS_STR));
			pending_data->error_handler (pending_data->data, message);
			nih_error_pop_context ();

			nih_free (message);
			dbus_message_unref (reply);
			return;
		}

		dbus_message_iter_recurse (&iter, &variter);

		/* Demarshal a char * from the message */
		if (dbus_message_iter_get_arg_type (&variter) != DBUS_TYPE_STRING) {
			nih_error_push_context ();
			nih_error_raise (NIH_DBUS_INVALID_ARGS,
			                 _(NIH_DBUS_INVALID_ARGS_STR));
			pending_data->error_handler (pending_data->data, message);
			nih_error_pop_context ();

			nih_free (message);
			dbus_message_unref (reply);
			return;
		}

		dbus_message_iter_get_basic (&variter, &value_dbus);

		value = nih_strdup (message, value_dbus);
		if (! value) {
			nih_free (message);
			message = NULL;
			goto enomem;
		}

		dbus_message_iter_next (&variter);

		dbus_message_iter_next (&iter);

		if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID) {
			nih_error_push_context ();
			nih_error_raise (NIH_DBUS_INVALID_ARGS,
			                 _(NIH_DBUS_INVALID_ARGS_STR));
			pending_data->error_handler (pending_data->data, message);
			nih_error_pop_context ();

			nih_free (message);
			dbus_message_unref (reply);
			return;
		}

	enomem: __attribute__ ((unused));
	} while (! message);

	/* Call the handler function */
	nih_error_push_context ();
	((MyGetPropertyReply)pending_data->handler) (pending_data->data, message, value);
	nih_error_pop_context ();

	nih_free (message);
	dbus_message_unref (reply);
}
Пример #18
0
#include <todoize_options.h>
#include <todoize_error.h>
#include <todoize_debug.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>

#ifdef SQLITE3
# define OPT_ADD_SQLITE3(x) (x "b:")
#else
# define OPT_ADD_SQLITE3(x) (x)
#endif /* SQLITE3 */

void todoize_options_close(__attribute__((unused)) t_todoize_options todoize_options)
{
#ifdef SQLITE3
  if (todoize_options.sql3_db)
    free(todoize_options.sql3_db);
#endif /* SQLITE3 */
}
/**
 * \param[out] todoize_options The struct to be initialized with the default values.
 * \brief Initialize todoize_options with default value.
 * \return Nothing (void)
 */
static inline void todoize_options_init(t_todoize_options* todoize_options)
{
  todoize_options->display_help = 0;
  todoize_options->display_version = 0;
Пример #19
0
/* Unused except in omp task pragmas */
void djbi1d_skewed_tiles(int num_strips, int num_steps, double *dashs,
                         double *slashs) {
  uint8_t taskdep_index[num_strips + 1][num_steps] __attribute__((unused));

#ifdef DEBUG_PARALLEL
  int *tsk = (int *)malloc(sizeof(int) * (num_strips + 1) * num_steps);
#endif
  int tile_i, tile_t;
#ifndef SEQ
#pragma omp parallel
#pragma omp master
#endif
  {
    for (tile_t = 0; tile_t < num_steps; tile_t++) {
      for (tile_i = 0; tile_i < num_strips + 1; tile_i++) {
        /* Strip number */
        int strpno = (tile_i + tile_t);

        if (tile_t == 0 && tile_i == 0) {
#ifndef SEQ
#pragma omp task firstprivate(tile_i, tile_t) depend(out : taskdep_index[0][0])
#endif
          {
#ifdef DEBUG_PARALLEL
            tsk[0] = 1;
#endif
            do_i0_t0(dashs, slashs, tile_i, tile_t);
          }
        } else if (tile_t == 0 && tile_i < num_strips - 1) {
/* Bottom tiles : only left-to-right dependencies + top out */
#ifndef SEQ
#pragma omp task firstprivate(tile_i, tile_t) depend( \
    in : taskdep_index[tile_i - 1][0])                \
        depend(out : taskdep_index[tile_i][tile_t])
#endif
          {
#ifdef DEBUG_PARALLEL
            if (tsk[tile_i - 1] != 1) {
              printf("Unsatisified dependency !\n");
            }
            tsk[tile_t * num_steps + tile_i] = 1;
#endif
            do_i_t(dashs, slashs, strpno, 0);
          }

        } else if (tile_i == 0 && tile_t > 0) {
/*
 * Left edge tile : triangular tiles
 * Only one in dependency, one out
 * ( here we assume T_ITERS == T_WIDTH_DBL )
 */
#ifndef SEQ
#pragma omp task firstprivate(tile_i, tile_t) depend( \
    in : taskdep_index[1][tile_t - 1])                \
        depend(out : taskdep_index[tile_i][tile_t])
#endif
          {
#ifdef DEBUG_PARALLEL
            if (tsk[(tile_t - 1) * num_steps + tile_i] != 1) {
              printf("Unsatisified dependency !\n");
            }
            tsk[tile_t * num_steps + tile_i] = 1;
#endif
            do_i0_t(dashs, slashs, strpno, tile_t);
          }
        } else if (tile_i == num_strips) {
#ifndef SEQ
#pragma omp task firstprivate(tile_i, tile_t) depend( \
    in : taskdep_index[tile_i - 1][tile_t])           \
        depend(out : taskdep_index[tile_i][tile_t])
#endif
          {
#ifdef DEBUG_PARALLEL
            if (tsk[tile_t * num_steps + tile_i - 1] != 1) {
              printf("Unsatisified dependency !\n");
            }
            tsk[tile_t * num_steps + tile_i] = 1;
#endif
            do_in_t(dashs, slashs, strpno, tile_t);
          }

        } else {
/* Regular tile two in and out dependencies */
#ifndef SEQ
#pragma omp task firstprivate(tile_i, tile_t) depend(                    \
    in : taskdep_index[tile_i - 1][tile_t],                              \
                                   taskdep_index[tile_i + 1][tile_t -    \
                                                             1]) depend( \
                                       out : taskdep_index[tile_i][tile_t])
#endif
          {
#ifdef DEBUG_PARALLEL
            if (tsk[tile_t * num_steps + tile_i - 1] != 1 ||
                tsk[(tile_t - 1) * num_steps + (tile_i + 1)] != 1) {
              printf("Unsatisified dependency !\n");
            }
            tsk[tile_t * num_steps + tile_i] = 1;
#endif
            do_i_t(dashs, slashs, strpno, tile_t);
          }
        }
      }
    }
  }
}
Пример #20
0
ppm_t* img_fast_sharpen_copy(ppm_t* src, ppm_t* dst, float k, uint64_t* cycles)
{
	int i = 0, j = 0;
	float temp = 0.0f;
	float PSF[12] __attribute__((aligned(16)))
		= {-k/8.0f, -k/8.0f, -k/8.0f, 0.0f, -k/8.0f, k+1.0f, -k/8.0f, 0.0f, -k/8.0f, -k/8.0f, -k/8.0f, 0.0f};
	float tempr[4] __attribute__((aligned(16)))
		= { 0.0f };
	
	__m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9;
	
	// Initialize data
	float* copyR = ppm_alloc_aligned_f(src->w, src->h);
	float* copyG = ppm_alloc_aligned_f(src->w, src->h);
	float* copyB = ppm_alloc_aligned_f(src->w, src->h);
	
	for (j = 0; j < src->w; j++)
	{
		for (i = 0; i < src->h; i++)
		{
			copyR[i + src->h*j] = (float)src->r[i + src->h*j];
			copyG[i + src->h*j] = (float)src->g[i + src->h*j];
			copyB[i + src->h*j] = (float)src->b[i + src->h*j];
			
			dst->r[i + src->h*j] = src->r[i + src->h*j];
			dst->g[i + src->h*j] = src->g[i + src->h*j];
			dst->b[i + src->h*j] = src->b[i + src->h*j];
		}
	}
	
	uint64_t t0 = readTSC();
	_mm_empty();
	
	xmm0 = _mm_load_ps(PSF);
	xmm1 = _mm_load_ps(PSF + 4);
	xmm2 = _mm_load_ps(PSF + 8);
	
	// Skip first and last row, no neighbors to convolve with
    for (j = 1; j < src->w - 1; j++)
    {
        // Skip first and last column, no neighbors to convolve with
        for (i = 1; i < src->h - 1; i++)
        {
            temp = 0.0f;

			// Load 9 values
			if ((i-1) % 4 == 0)
			{
				xmm3 = _mm_load_ps(&copyR[i + (j-1)*src->h] - 1);
				xmm4 = _mm_load_ps(&copyR[i + (j)*src->h] - 1);
				xmm5 = _mm_load_ps(&copyR[i + (j+1)*src->h] - 1);
			}
			else
			{
				xmm3 = _mm_loadu_ps(&copyR[i + (j-1)*src->h] - 1);
				xmm4 = _mm_loadu_ps(&copyR[i + (j)*src->h] - 1);
				xmm5 = _mm_loadu_ps(&copyR[i + (j+1)*src->h] - 1);
			}
			
			// Multiply
			xmm6 = _mm_mul_ps(xmm0, xmm3);
			xmm7 = _mm_mul_ps(xmm1, xmm4);
			xmm8 = _mm_mul_ps(xmm2, xmm5);
			
			// Add
			xmm9 = _mm_add_ps(xmm6, _mm_add_ps(xmm7, xmm8));
			_mm_store_ps(tempr, xmm9);
			
			temp = tempr[0] + tempr[1] + tempr[2];
			if (temp < 0.0f) temp = 0.0f;
			if (temp > (float)src->max) temp = (float)src->max;
			
			dst->r[i + src->h*j] = (uint8_t)temp;
			temp = 0.0f;
			
            // Load 9 values
			if ((i-1) % 4 == 0)
			{
				xmm3 = _mm_load_ps(&copyG[i + (j-1)*src->h] - 1);
				xmm4 = _mm_load_ps(&copyG[i + (j)*src->h] - 1);
				xmm5 = _mm_load_ps(&copyG[i + (j+1)*src->h] - 1);
			}
			else
			{
				xmm3 = _mm_loadu_ps(&copyG[i + (j-1)*src->h] - 1);
				xmm4 = _mm_loadu_ps(&copyG[i + (j)*src->h] - 1);
				xmm5 = _mm_loadu_ps(&copyG[i + (j+1)*src->h] - 1);
			}
			
			// Multiply
			xmm6 = _mm_mul_ps(xmm0, xmm3);
			xmm7 = _mm_mul_ps(xmm1, xmm4);
			xmm8 = _mm_mul_ps(xmm2, xmm5);
			
			// Add
			xmm9 = _mm_add_ps(xmm6, _mm_add_ps(xmm7, xmm8));
			_mm_store_ps(tempr, xmm9);
			
			temp = tempr[0] + tempr[1] + tempr[2];
			if (temp < 0.0f) temp = 0.0f;
			if (temp > (float)src->max) temp = (float)src->max;
			
			dst->g[i + src->h*j] = (uint8_t)temp;
			temp = 0.0f;
			
			// Load 9 values
			if ((i-1) % 4 == 0)
			{
				xmm3 = _mm_load_ps(&copyB[i + (j-1)*src->h] - 1);
				xmm4 = _mm_load_ps(&copyB[i + (j)*src->h] - 1);
				xmm5 = _mm_load_ps(&copyB[i + (j+1)*src->h] - 1);
			}
			else
			{
				xmm3 = _mm_loadu_ps(&copyB[i + (j-1)*src->h] - 1);
				xmm4 = _mm_loadu_ps(&copyB[i + (j)*src->h] - 1);
				xmm5 = _mm_loadu_ps(&copyB[i + (j+1)*src->h] - 1);
			}
			
			// Multiply
			xmm6 = _mm_mul_ps(xmm0, xmm3);
			xmm7 = _mm_mul_ps(xmm1, xmm4);
			xmm8 = _mm_mul_ps(xmm2, xmm5);
			
			// Add
			xmm9 = _mm_add_ps(xmm6, _mm_add_ps(xmm7, xmm8));
			_mm_store_ps(tempr, xmm9);
			
			temp = tempr[0] + tempr[1] + tempr[2];
			if (temp < 0.0f) temp = 0.0f;
			if (temp > (float)src->max) temp = (float)src->max;
			
			dst->b[i + src->h*j] = (uint8_t)temp;
        }
    }
	
	_mm_empty();
	
	if (cycles != NULL) *cycles = cyclesElapsed(readTSC(), t0);

	#ifdef __INTEL_COMPILER
	_mm_free(copyR);
	#else
	free(copyR);
	#endif
	
	#ifdef __INTEL_COMPILER
	_mm_free(copyG);
	#else
	free(copyG);
	#endif
	
	#ifdef __INTEL_COMPILER
	_mm_free(copyB);
	#else
	free(copyB);
	#endif
	
	return dst;
}
Пример #21
0
   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library.  If not, see
   <http://www.gnu.org/licenses/>.  */

#define HAVE_ARCH_PLTENTER
#define HAVE_ARCH_PLTEXIT

#include <elf/sotruss-lib.c>

ElfW(Addr)
la_aarch64_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
			 unsigned int ndx __attribute__ ((unused)),
			 uintptr_t *refcook, uintptr_t *defcook,
			 La_aarch64_regs *regs, unsigned int *flags,
			 const char *symname, long int *framesizep)
{
  print_enter (refcook, defcook, symname,
	       regs->lr_xreg[0], regs->lr_xreg[1], regs->lr_xreg[2],
	       *flags);

  /* No need to copy anything, we will not need the parameters in any case.  */
  *framesizep = 0;

  return sym->st_value;
}
Пример #22
0
ppm_t* img_fast_sharpen(ppm_t* src, ppm_t* dst, float k, uint64_t* cycles)
{
	int i = 0, j = 0;
	float temp = 0.0f;
	float PSF[12] __attribute__((aligned(16)))
		= {-k/8.0f, -k/8.0f, -k/8.0f, 0.0f, -k/8.0f, k+1.0f, -k/8.0f, 0.0f, -k/8.0f, -k/8.0f, -k/8.0f, 0.0f};
	float tempr[4] __attribute__((aligned(16)))
		= { 0.0f };
	int mask[4] __attribute__((aligned(16)))
		= { 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000 };
	
	__m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9;
	__m128i xmm11;
	
	memcpy(dst->r, src->r, src->h*src->w*sizeof(uint8_t));
	memcpy(dst->g, src->g, src->h*src->w*sizeof(uint8_t));
	memcpy(dst->b, src->b, src->h*src->w*sizeof(uint8_t));
	
	uint64_t t0 = readTSC();
	_mm_empty();
	
	xmm0 = _mm_load_ps(PSF);
	xmm1 = _mm_load_ps(PSF + 4);
	xmm2 = _mm_load_ps(PSF + 8);
	
	// Skip first and last row, no neighbors to convolve with
    for (j = 1; j < src->w - 1; j++)
    {
        // Skip first and last column, no neighbors to convolve with
        for (i = 1; i < src->h - 1; i++)
        {
            temp = 0.0f;
			
			// Load 9 values
			//xmm3 = _mm_cvtpu8_ps(*(__m64*)&src->r[i + (j-1)*src->h - 1]);
			//xmm4 = _mm_cvtpu8_ps(*(__m64*)&src->r[i + (j)*src->h - 1]);
			//xmm5 = _mm_cvtpu8_ps(*(__m64*)&src->r[i + (j+1)*src->h - 1]);
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->r[i + (j-1)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm3 = _mm_cvtepi32_ps(xmm11);
			
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->r[i + (j)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm4 = _mm_cvtepi32_ps(xmm11);
			
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->r[i + (j+1)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm5 = _mm_cvtepi32_ps(xmm11);
			
			// Multiply
			xmm6 = _mm_mul_ps(xmm0, xmm3);
			xmm7 = _mm_mul_ps(xmm1, xmm4);
			xmm8 = _mm_mul_ps(xmm2, xmm5);
			
			// Add
			xmm9 = _mm_add_ps(xmm6, _mm_add_ps(xmm7, xmm8));
			
			_mm_store_ps(tempr, xmm9);
			temp = tempr[0] + tempr[1] + tempr[2];
			
			if (temp < 0.0f) temp = 0.0f;
			if (temp > (float)src->max) temp = (float)src->max;
			
			dst->r[i + src->h*j] = (uint8_t)temp;
			temp = 0.0f;
			
            // Load 9 values
			//xmm3 = _mm_cvtpu8_ps(*(__m64*)&src->g[i + (j-1)*src->h - 1]);
			//xmm4 = _mm_cvtpu8_ps(*(__m64*)&src->g[i + (j)*src->h - 1]);
			//xmm5 = _mm_cvtpu8_ps(*(__m64*)&src->g[i + (j+1)*src->h - 1]);
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->g[i + (j-1)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm3 = _mm_cvtepi32_ps(xmm11);
			
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->g[i + (j)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm4 = _mm_cvtepi32_ps(xmm11);
			
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->g[i + (j+1)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm5 = _mm_cvtepi32_ps(xmm11);
			
			// Multiply
			xmm6 = _mm_mul_ps(xmm0, xmm3);
			xmm7 = _mm_mul_ps(xmm1, xmm4);
			xmm8 = _mm_mul_ps(xmm2, xmm5);
			
			// Add
			xmm9 = _mm_add_ps(xmm6, _mm_add_ps(xmm7, xmm8));
			
			_mm_store_ps(tempr, xmm9);
			temp = tempr[0] + tempr[1] + tempr[2];
			
			if (temp < 0.0f) temp = 0.0f;
			if (temp > (float)src->max) temp = (float)src->max;
			
			dst->g[i + src->h*j] = (uint8_t)temp;
			temp = 0.0f;
			
			// Load 9 values
			//xmm3 = _mm_cvtpu8_ps(*(__m64*)&src->b[i + (j-1)*src->h - 1]);
			//xmm4 = _mm_cvtpu8_ps(*(__m64*)&src->b[i + (j)*src->h - 1]);
			//xmm5 = _mm_cvtpu8_ps(*(__m64*)&src->b[i + (j+1)*src->h - 1]);
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->b[i + (j-1)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm3 = _mm_cvtepi32_ps(xmm11);
			
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->b[i + (j)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm4 = _mm_cvtepi32_ps(xmm11);
			
			xmm11 = _mm_cvtsi32_si128(*(const int*)&src->b[i + (j+1)*src->h - 1]);
			xmm11 = _mm_unpacklo_epi8(xmm11, _mm_setzero_si128());
			xmm11 = _mm_unpacklo_epi16(xmm11, _mm_setzero_si128());
			xmm5 = _mm_cvtepi32_ps(xmm11);
			
			// Multiply
			xmm6 = _mm_mul_ps(xmm0, xmm3);
			xmm7 = _mm_mul_ps(xmm1, xmm4);
			xmm8 = _mm_mul_ps(xmm2, xmm5);
			
			// Add
			xmm9 = _mm_add_ps(xmm6, _mm_add_ps(xmm7, xmm8));
			
			_mm_store_ps(tempr, xmm9);
			temp = tempr[0] + tempr[1] + tempr[2];
			
			if (temp < 0.0f) temp = 0.0f;
			if (temp > (float)src->max) temp = (float)src->max;
			
			dst->b[i + src->h*j] = (uint8_t)temp;
        }
    }
	
	_mm_empty();
	if (cycles != NULL) *cycles = cyclesElapsed(readTSC(), t0);
	
	return dst;
}
Пример #23
0
      if (*src!=transp_color)
        *dest=color;

      // On passe au pixel suivant
      src++;
      dest++;
    }

    // On passe à la ligne suivante
    src+=brush_width-width;
    dest+=VIDEO_LINE_WIDTH-width;
  }
  Update_rect(x_pos,y_pos,width,height);
}

void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{
  byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
  byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
  int y;

  for(y=height;y!=0;y--)
  // Pour chaque ligne
  {
    // On fait une copie de la ligne
    memcpy(dest,src,width);

    // On passe à la ligne suivante
    src+=image_width;
    dest+=VIDEO_LINE_WIDTH;
  }
Пример #24
0
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <elf.h>
#include <stddef.h>
#include <string.h>

#define BACKEND		aarch64_
#include "libebl_CPU.h"


/* Check for the simple reloc types.  */
Elf_Type
aarch64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
{
  switch (type)
    {
    case R_AARCH64_ABS64:
      return ELF_T_XWORD;
    case R_AARCH64_ABS32:
      return ELF_T_WORD;
    case R_AARCH64_ABS16:
      return ELF_T_HALF;

    default:
      return ELF_T_NUM;
    }
}
Пример #25
0
		thr = completed_thr;
		que_thr_init_command(thr);
	}

	return(thr);
}

/**********************************************************************//**
After signal handling is finished, returns control to a query graph error
handling routine. (Currently, just returns the control to the root of the
graph so that the graph can communicate an error message to the client.) */
UNIV_INTERN
void
que_fork_error_handle(
/*==================*/
	trx_t*	trx __attribute__((unused)),	/*!< in: trx */
	que_t*	fork)	/*!< in: query graph which was run before signal
			handling started, NULL not allowed */
{
	que_thr_t*	thr;

	ut_ad(mutex_own(&kernel_mutex));
	ut_ad(trx->sess->state == SESS_ERROR);
	ut_ad(UT_LIST_GET_LEN(trx->reply_signals) == 0);
	ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0);

	thr = UT_LIST_GET_FIRST(fork->thrs);

	while (thr != NULL) {
		ut_ad(!thr->is_active);
		ut_ad(thr->state != QUE_THR_SIG_REPLY_WAIT);
/** magnetometer */
#ifndef INS_FINV_MAG_ID
#define INS_FINV_MAG_ID ABI_BROADCAST
#endif
PRINT_CONFIG_VAR(INS_FINV_MAG_ID)

static abi_event baro_ev;
static abi_event mag_ev;
static abi_event gyro_ev;
static abi_event accel_ev;
static abi_event aligner_ev;
static abi_event body_to_imu_ev;
static abi_event geo_mag_ev;
static abi_event gps_ev;

static void baro_cb(uint8_t __attribute__((unused)) sender_id, float pressure)
{
  ins_float_invariant_update_baro(pressure);
}

/**
 * Call ins_float_invariant_propagate on new gyro measurements.
 * Since acceleration measurement is also needed for propagation,
 * use the last stored accel from #ins_finv_accel.
 */
static void gyro_cb(uint8_t sender_id __attribute__((unused)),
                   uint32_t stamp, struct Int32Rates *gyro)
{
#if USE_AUTO_INS_FREQ || !defined(INS_PROPAGATE_FREQUENCY)
  PRINT_CONFIG_MSG("Calculating dt for INS float_invariant propagation.")
  /* timestamp in usec when last callback was received */
Пример #27
0
/*
** fct_ebo.c for PSU_2015_zappy in /home/mikaz3
**
** Made by Thomas Billot
** Login   <*****@*****.**>
**
** Started on  Thu Jun 16 14:29:28 2016 Thomas Billot
** Last update Thu Jun 16 17:17:30 2016 Thomas Beaudet
*/

#include <stdlib.h>
#include <stdio.h>
#include "../graphical.h"

int		fct_ebo(t_map *map,
			t_server *server __attribute__((unused)),
			char **cmd)
{
  int		i;

  (void)map;
  i = 0;
  printf("fct_%s args:", cmd[i]);
  while (cmd[++i])
    printf(" %s |", cmd[i]);
  printf("\n");
  return (0);
}
Пример #28
0
  }

  time_delta = msec_of_sys_time_ticks(clock_delta);

  itow_now = gps_time_sync.t0_tow + time_delta;
  if (itow_now > MSEC_PER_WEEK) {
    itow_now %= MSEC_PER_WEEK;
  }

  return itow_now;
}

/**
 * Default parser for GPS injected data
 */
void WEAK gps_inject_data(uint8_t packet_id __attribute__((unused)), uint8_t length __attribute__((unused)), uint8_t *data __attribute__((unused))){

}

/**
 * Convenience function to get utm position from GPS state
 */
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
{
  struct UtmCoor_f utm;
  utm.alt = 0.f;

  if (bit_is_set(gps_s->valid_fields, GPS_VALID_POS_UTM_BIT)) {
    // A real UTM position is available, use the correct zone
    utm.zone = gps_s->utm_pos.zone;
    utm.east = gps_s->utm_pos.east / 100.0f;
Пример #29
0
bool rboot_verify_image(uint32_t initial_offset, uint32_t *image_length, const char **error_message)
{
    uint32_t offset = initial_offset;
    char *error = NULL;
    RBOOT_DEBUG("rboot_verify_image: verifying image at 0x%08x\n", initial_offset);
    if(offset % 4) {
        error = "Unaligned flash offset";
        goto fail;
    }

    /* sanity limit on how far we can read */
    uint32_t end_limit = offset + 0x100000;
    image_header_t image_header __attribute__((aligned(4)));
    if(sdk_spi_flash_read(offset, (uint32_t *)&image_header, sizeof(image_header_t))) {
        error = "Flash fail";
        goto fail;
    }

    offset += sizeof(image_header_t);

    if(image_header.magic != ROM_MAGIC_OLD && image_header.magic != ROM_MAGIC_NEW) {
        error = "Missing initial magic";
        goto fail;
    }

    bool is_new_header = (image_header.magic == ROM_MAGIC_NEW); /* a v1.2/rboot header, so expect a v1.1 header after the initial section */

    int remaining_sections = image_header.section_count;

    uint8_t checksum = CHKSUM_INIT;

    while(remaining_sections > 0 && offset < end_limit)
    {
        /* read section header */
        section_header_t header __attribute__((aligned(4)));
        if(sdk_spi_flash_read(offset, (uint32_t *)&header, sizeof(section_header_t))) {
            error = "Flash fail";
            goto fail;
        }

        RBOOT_DEBUG("Found section @ 0x%08x (abs 0x%08x) length %d load 0x%08x\n", offset-initial_offset, offset, header.length, header.load_addr);
        offset += sizeof(section_header_t);

        if(header.length+offset > end_limit) {
            break; /* sanity check: will reading section take us off end of expected flashregion? */
        }

        if(header.length % 4) {
            error = "Header length not modulo 4";
            goto fail;
        }

        if(!is_new_header) {
            /* Add individual data of the section to the checksum. */
            char chunk[16] __attribute__((aligned(4)));
            for(int i = 0; i < header.length; i++) {
                if(i % sizeof(chunk) == 0)
                    sdk_spi_flash_read(offset+i, (uint32_t *)chunk, sizeof(chunk));
                checksum ^= chunk[i % sizeof(chunk)];
            }
        }

        offset += header.length;
        /* pad section to 4 byte align */
        offset = (offset+3) & ~3;

        remaining_sections--;

        if(is_new_header) {
            /* pad to a 16 byte offset */
            offset = (offset+15) & ~15;

            /* expect a v1.1 header here at start of "real" sections */
            sdk_spi_flash_read(offset, (uint32_t *)&image_header, sizeof(image_header_t));
            offset += sizeof(image_header_t);
            if(image_header.magic != ROM_MAGIC_OLD) {
                error = "Bad second magic";
                goto fail;
            }
            remaining_sections = image_header.section_count;
            is_new_header = false;
        }
    }
Пример #30
0
msg_t data_udp_send_thread(void *p) {
	void * arg __attribute__ ((unused)) = p;

	static const evhandler_t evhndl_imu_a[]       = {
			data_udp_send_mpu9150_data,
			data_udp_send_mpl3115a2_data,
			data_udp_send_adis16405_data
	};
	struct EventListener     evl_mpu9150;
    struct EventListener     evl_mpl3115a2;
	struct EventListener     evl_adis16405;

	err_t                    err_mpu_conn;
	err_t                    err_mpl_conn;
	err_t                    err_adis_conn;

	ip_addr_t                ip_addr_sensor;
	ip_addr_t                ip_addr_fc;

	chRegSetThreadName("data_udp_send_thread");

	chEvtRegister(&mpu9150_data_event,                   &evl_mpu9150,           0);
	chEvtRegister(&mpl3115a2_data_event,                 &evl_mpl3115a2,         1);
	chEvtRegister(&adis_spi_burst_data_captured,         &evl_adis16405,         2);

	IMU_A_IP_ADDR(&ip_addr_sensor);
	IP_PSAS_FC(&ip_addr_fc);

	mpu9150_mac_info.conn   = netconn_new( NETCONN_UDP );
	if(mpu9150_mac_info.conn == NULL) {
		log_error("mpu new conn is null");
		while(1);
	}

    mpl3115a2_mac_info.conn   = netconn_new( NETCONN_UDP );
    if(mpl3115a2_mac_info.conn == NULL) {
        log_error("mpl new conn is null");
        while(1);
    }

	adis16405_mac_info.conn   = netconn_new( NETCONN_UDP );
	if(adis16405_mac_info.conn == NULL) {
		log_error("adis new conn is null");
		while(1);
	}

	/* Bind to the local address, or to ANY address */
	//	netconn_bind(conn, NULL, DATA_UDP_TX_THREAD_PORT ); //local port, NULL is bind to ALL ADDRESSES! (IP_ADDR_ANY)
	err_mpu_conn   = netconn_bind(mpu9150_mac_info.conn,   &ip_addr_sensor, IMU_A_TX_PORT_MPU ); //local port

	if (err_mpu_conn != ERR_OK) {
		log_error("mpu bind is not OK");
		while(1);
	}

	err_mpl_conn   = netconn_bind(mpl3115a2_mac_info.conn,   &ip_addr_sensor, IMU_A_TX_PORT_MPL ); //local port

	if (err_mpl_conn != ERR_OK) {
	    log_error("mpl bind is not OK");
	    while(1);
	}

	err_adis_conn   = netconn_bind(adis16405_mac_info.conn,   &ip_addr_sensor, IMU_A_TX_PORT_ADIS ); //local port
	if (err_adis_conn != ERR_OK) {
		log_error("adis bind is not OK");
		while(1);
	}

	if ((err_mpu_conn == ERR_OK) && (err_adis_conn == ERR_OK)) {
		/* Connect to specific address or a broadcast address */
		/*
		 * \todo Understand why a UDP needs a connect...
		 *   This may be a LwIP thing that chooses between tcp_/udp_/raw_ connections internally.
		 *
		 */
	    //	netconn_connect(conn, IP_ADDR_BROADCAST, DATA_UDP_TX_THREAD_PORT );
	    err_mpu_conn  = netconn_connect(mpu9150_mac_info.conn,   &ip_addr_fc, FC_LISTEN_PORT_IMU_A );
	    if (err_mpu_conn != ERR_OK) {
	        log_error("mpu port connect is not OK");
	        while(1);
	    }

	    err_mpl_conn  = netconn_connect(mpl3115a2_mac_info.conn,   &ip_addr_fc, FC_LISTEN_PORT_IMU_A );
	    if (err_mpl_conn != ERR_OK) {
	        log_error("mpl port connect is not OK");
	        while(1);
	    }

	    err_adis_conn = netconn_connect(adis16405_mac_info.conn, &ip_addr_fc, FC_LISTEN_PORT_IMU_A);
	    if (err_adis_conn != ERR_OK) {
	        log_error("adis port connect is not OK");
	        while(1);
	    }

	    if(err_mpu_conn == ERR_OK) {
	        while (TRUE) {
	            chEvtDispatch(evhndl_imu_a, chEvtWaitOneTimeout(EVENT_MASK(2)| EVENT_MASK(1)|EVENT_MASK(0), MS2ST(50)));
	        }
	    } else {
	        log_error("Conn not ok");
	    }
	    return RDY_RESET;
	} else {
	    log_error("2 conn not ok");
	}
	return RDY_RESET;
}