1
/* amber.c, this file is part of the
2
* AltiVec optimized library for MJPEG tools MPEG-1/2 Video Encoder
3
* Copyright (C) 2002 James Klicman <james@klicman.org>
5
* This library 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; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
#ifdef HAVE_SYS_TYPES_H
30
#include <sys/types.h>
32
#include <sys/errno.h>
36
#include "../mjpeg_logging.h"
38
#define SIGNAL_AMBER() \
39
({register long _value; \
40
asm volatile ("mfspr %0, 1023" : "=r" (_value) ); \
44
long amber_start(const char *file, int line, int *trace_count, int max_traces)
50
if (*trace_count < max_traces) {
52
mjpeg_info("amber start %s:%d", file, line);
54
value = SIGNAL_AMBER();
60
long amber_stop(const char *file, int line, int *trace_count, int max_traces,
65
if (*trace_count < max_traces) {
66
value = SIGNAL_AMBER();
68
mjpeg_info("amber stop %s:%d", file, line);
71
if (max_exit && *trace_count >= max_traces)
81
void amber_symtrace(const char *name) {
85
char tracename[PATH_MAX], sympath[PATH_MAX], symname[PATH_MAX];
88
if ((dp = opendir(".")) == NULL)
89
mjpeg_error_exit1("can't open current directory");
91
while ((dir = readdir(dp)) != NULL) {
95
if (strncmp(dir->d_name, "trace_", 6) == 0) {
98
strncpy(tracename, dir->d_name, PATH_MAX);
100
if (strncmp(dir->d_name, tracename, PATH_MAX) > 0)
101
strncpy(tracename, dir->d_name, PATH_MAX);
108
if (stat(name, &sb) != 0 && errno == ENOENT) {
109
if (mkdir(name, 0777) != 0)
110
mjpeg_error_exit1("can't make directory %s", name);
112
snprintf(sympath, PATH_MAX, "../%s", tracename);
113
snprintf(symname, PATH_MAX, "%s/%s", name, tracename);
114
if (symlink(sympath, symname) != 0)
115
mjpeg_error_exit1("can't symlink %s to %s", tracename, symname);
117
mjpeg_error_exit1("trace not found");