build.c revision 1.3
11.2Snonaka/* $NetBSD: build.c,v 1.3 2012/06/01 13:19:39 nonaka Exp $ */ 21.3Snonaka/* $OpenBSD: build.c,v 1.1 2006/01/09 20:03:40 damien Exp $ */ 31.1Sjoerg 41.1Sjoerg/*- 51.1Sjoerg * Copyright (c) 2006 61.1Sjoerg * Damien Bergamini <damien.bergamini@free.fr> 71.1Sjoerg * 81.1Sjoerg * Permission to use, copy, modify, and distribute this software for any 91.1Sjoerg * purpose with or without fee is hereby granted, provided that the above 101.1Sjoerg * copyright notice and this permission notice appear in all copies. 111.1Sjoerg * 121.1Sjoerg * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 131.1Sjoerg * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 141.1Sjoerg * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 151.1Sjoerg * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 161.1Sjoerg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 171.1Sjoerg * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 181.1Sjoerg * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 191.1Sjoerg */ 201.1Sjoerg 211.1Sjoerg#include <sys/types.h> 221.1Sjoerg 231.1Sjoerg#include <err.h> 241.1Sjoerg#include <fcntl.h> 251.1Sjoerg#include <stdio.h> 261.1Sjoerg#include <unistd.h> 271.1Sjoerg 281.1Sjoerg#include "microcode.h" 291.1Sjoerg 301.1Sjoergstatic void 311.1Sjoergoutput(const char *name, const uint8_t *ucode, int size) 321.1Sjoerg{ 331.1Sjoerg ssize_t rlen; 341.1Sjoerg int fd; 351.1Sjoerg 361.1Sjoerg printf("creating %s length %d\n", name, size); 371.1Sjoerg 381.1Sjoerg fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644); 391.1Sjoerg if (fd == -1) 401.1Sjoerg err(1, "%s", name); 411.1Sjoerg 421.1Sjoerg rlen = write(fd, ucode, size); 431.1Sjoerg if (rlen == -1) 441.1Sjoerg err(1, "%s", name); 451.1Sjoerg if (rlen != size) 461.1Sjoerg errx(1, "%s: short write", name); 471.1Sjoerg 481.1Sjoerg close(fd); 491.1Sjoerg} 501.1Sjoerg 511.1Sjoergint 521.1Sjoergmain(void) 531.1Sjoerg{ 541.3Snonaka output("rum-rt2573", rt2573, sizeof rt2573); 551.1Sjoerg 561.1Sjoerg return 0; 571.1Sjoerg} 58