/* * TCC - Tiny C Compiler * * Copyright (c) 2001-2004 Fabrice Bellard * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This 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 this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "tcc.h" /********************************************************/ /* global variables */ /* loc : local variable index ind : output code index rsym: return symbol anon_sym: anonymous symbol index */ ST_DATA int rsym, anon_sym, ind, loc; ST_DATA Sym *sym_free_first; ST_DATA void **sym_pools; ST_DATA int nb_sym_pools; ST_DATA Sym *global_stack; ST_DATA Sym *local_stack; ST_DATA Sym *define_stack; ST_DATA Sym *global_label_stack; ST_DATA Sym *local_label_stack; static int local_scope; static int in_sizeof; static int section_sym; ST_DATA int vlas_in_scope; /* number of VLAs that are currently in scope */ ST_DATA int vla_sp_root_loc; /* vla_sp_loc for SP before any VLAs were pushed */ ST_DATA int vla_sp_loc; /* Pointer to variable holding location to store stack pointer on the stack when modifying stack pointer */ ST_DATA SValue __vstack[1+VSTACK_SIZE], *vtop, *pvtop; ST_DATA int const_wanted; /* true if constant wanted */ ST_DATA int nocode_wanted; /* no code generation wanted */ #define NODATA_WANTED (nocode_wanted > 0) /* no static data output wanted either */ #define STATIC_DATA_WANTED (nocode_wanted & 0xC0000000) /* only static data output */ ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */ ST_DATA CType func_vt; /* current function return type (used by return instruction) */ ST_DATA int func_var; /* true if current function is variadic (used by return instruction) */ ST_DATA int func_vc; ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */ ST_DATA const char *funcname; ST_DATA int g_debug; ST_DATA CType char_pointer_type, func_old_type, int_type, size_type, ptrdiff_type; ST_DATA struct switch_t { struct case_t { int64_t v1, v2; int sym; } **p; int n; /* list of case ranges */ int def_sym; /* default symbol */ } *cur_switch; /* current switch */ /* ------------------------------------------------------------------------- */ static void gen_cast(CType *type); static void gen_cast_s(int t); static inline CType *pointed_type(CType *type); static int is_compatible_types(CType *type1, CType *type2); static int parse_btype(CType *type, AttributeDef *ad); static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td); static void parse_expr_type(CType *type); static void init_putv(CType *type, Section *sec, unsigned long c); static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only); static void block(int *bsym, int *csym, int is_expr); static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, int has_init, int v, int scope); static void decl(int l); static int decl0(int l, int is_for_loop_init, Sym *); static void expr_eq(void); static void vla_runtime_type_size(CType *type, int *a); static void vla_sp_restore(void); static void vla_sp_restore_root(void); static int is_compatible_unqualified_types(CType *type1, CType *type2); static inline int64_t expr_const64(void); static void vpush64(int ty, unsigned long long v); static void vpush(CType *type); static int gvtst(int inv, int t); static void gen_inline_functions(TCCState *s); static void skip_or_save_block(TokenString **str); static void gv_dup(void); ST_INLN int is_float(int t) { int bt; bt = t & VT_BTYPE; return bt == VT_LDOUBLE || bt == VT_DOUBLE || bt == VT_FLOAT || bt == VT_QFLOAT; } /* we use our own 'finite' function to avoid potential problems with non standard math libs */ /* XXX: endianness dependent */ ST_FUNC int ieee_finite(double d) { int p[4]; memcpy(p, &d, sizeof(double)); return ((unsigned)((p[1] | 0x800fffff) + 1)) >> 31; } /* compiling intel long double natively */ #if (defined __i386__ || defined __x86_64__) \ && (defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64) # define TCC_IS_NATIVE_387 #endif ST_FUNC void test_lvalue(void) { if (!(vtop->r & VT_LVAL)) expect("lvalue"); } ST_FUNC void check_vstack(void) { if (pvtop != vtop) tcc_error("internal compiler error: vstack leak (%d)", vtop - pvtop); } /* ------------------------------------------------------------------------- */ /* vstack debugging aid */ #if 0 void pv (const char *lbl, int a, int b) { int i; for (i = a; i < a + b; ++i) { SValue *p = &vtop[-i]; printf("%s vtop[-%d] : type.t:%04x r:%04x r2:%04x c.i:%d\n", lbl, i, p->type.t, p->r, p->r2, (int)p->c.i); } } #endif /* ------------------------------------------------------------------------- */ /* start of translation unit info */ ST_FUNC void tcc_debug_start(TCCState *s1) { if (s1->do_debug) { char buf[512]; /* file info: full path + filename */ section_sym = put_elf_sym(symtab_section, 0, 0, ELFW(ST_INFO)(STB_LOCAL, STT_SECTION), 0, text_section->sh_num, NULL); getcwd(buf, sizeof(buf)); #ifdef _WIN32 normalize_slashes(buf); #endif pstrcat(buf, sizeof(buf), "/"); put_stabs_r(buf, N_SO, 0, 0, text_section->data_offset, text_section, section_sym); put_stabs_r(file->filename, N_SO, 0, 0, text_section->data_offset, text_section, section_sym); last_ind = 0; last_line_num = 0; } /* an elf symbol of type STT_FILE must be put so that STB_LOCAL symbols can be safely used */ put_elf_sym(symtab_section, 0, 0, ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0, SHN_ABS, file->filename); } /* put end of translation unit info */ ST_FUNC void tcc_debug_end(TCCState *s1) { if (!s1->do_debug) return; put_stabs_r(NULL, N_SO, 0, 0, text_section->data_offset, text_section, section_sym); } /* generate line number info */ ST_FUNC void tcc_debug_line(TCCState *s1) { if (!s1->do_debug) return; if ((last_line_num != file->line_num || last_ind != ind)) { put_stabn(N_SLINE, 0, file->line_num, ind - func_ind); last_ind = ind; last_line_num = file->line_num; } } /* put function symbol */ ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym) { char buf[512]; if (!s1->do_debug) return; /* stabs info */ /* XXX: we put here a dummy type */ snprintf(buf, sizeof(buf), "%s:%c1", funcname, sym->type.t & VT_STATIC ? 'f' : 'F'); put_stabs_r(buf, N_FUN, 0, file->line_num, 0, cur_text_section, sym->c); /* //gr gdb wants a line at the function */ put_stabn(N_SLINE,
.TH DWM 1 dwm-VERSION
.SH NAME
dwm \- dynamic window manager
.SH SYNOPSIS
.B dwm
.RB [ \-v ]
.SH DESCRIPTION
dwm is a dynamic window manager for X. It manages windows in tiling and
floating modes. Either mode can be applied dynamically, optimizing the
environment for the application in use and the task performed.
.P
In tiling mode windows are managed in a master and stacking area. The master
area contains the window which currently needs most attention, whereas the
stacking area contains all other windows. In floating mode windows can be
resized and moved freely. Dialog windows are always managed floating,
regardless of the mode selected.
.P
Windows are grouped by tags. Each window can be tagged with one or multiple
tags. Selecting certain tags displays all windows with these tags.
.P
dwm contains a small status bar which displays all available tags, the mode,
the title of the focused window, and the text read from standard input. The
selected tags are indicated with a different color. The tags of the focused
window are indicated with a filled square in the top left corner. The tags
which are applied to one or more windows are indicated with an empty square in
the top left corner.
.P
dwm draws a 1-pixel border around windows to indicate the focus state.
Unfocused windows contain a small bar in front of them displaying their title.
.SH OPTIONS
.TP
.B \-v
prints version information to standard output, then exits.
.SH USAGE
.SS Status bar
.TP
.B Standard input
is read and displayed in the status text area.
.TP
.B Button1
click on a tag label to display all windows with that tag, click on the mode
label toggles between tiling and floating mode.
.TP
.B Button3
click on a tag label adds/removes all windows with that tag to/from the view.
.TP
.B Mod1-Button1
click on a tag label applies that tag to the focused window.
.TP
.B Mod1-Button3
click on a tag label adds/removes that tag to/from the focused window.
.SS Keyboard commands
.TP
.B Mod1-Shift-Return
Start
.BR xterm (1).
.TP
.B Mod1-Tab
Focus next window.
.TP
.B Mod1-Shift-Tab
Focus previous window.
.TP
.B Mod1-Return
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
.TP
.B Mod1-g
Grow master area (tiling mode only).
.TP
.B Mod1-s
Shrink master area (tiling mode only).
.TP
.B Mod1-Shift-[1..n]
Apply
.RB nth
tag to current window.
.TP
.B Mod1-Shift-0
Apply all tags to current window.
.TP
.B Mod1-Control-Shift-[1..n]
Add/remove
.B nth
tag to/from current window.
.TP
.B Mod1-Shift-c
Close focused window.
.TP
.B Mod1-space
Toggle between tiling and floating mode (affects all windows).
.TP
.B Mod1-Shift-space
Toggle focused window between floating and non-floating state (tiling mode only).
.TP
.B Mod1-[1..n]
View all windows with
.BR nth
tag.
.TP
.B Mod1-0
View all windows with any tag.
.TP
.B Mod1-Control-[1..n]
Add/remove all windows with
.BR nth
tag to/from the view.
.TP
.B Mod1-Shift-q
Quit dwm.
.SS Mouse commands
.TP
.B Mod1-Button1
Move current window while dragging (floating mode only).
.TP
.B Mod1-Button2
Zoom current window to the master area (tiling mode only).
.TP
.B Mod1-Button3
Resize current window while dragging (floating mode only).
.SH CUSTOMIZATION
dwm is customized by creating a custom config.h and (re)compiling the source
code. This keeps it fast, secure and simple.
.SH CAVEATS
The status bar may display
.BR "EOF"
when dwm has been started by an X session manager like
.BR xdm (1),
because those close standard output before executing dwm.
.P
Java applications which use the XToolkit/XAWT backend may draw grey windows
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
JDK 1.6 versions, because it assumes a reparenting window manager. As a workaround
you can use JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or you
can set the following environment variable (to use the older Motif
backend instead):
.BR AWT_TOOLKIT=MToolkit .
.SH SEE ALSO
.BR dmenu (1)